Skip to content

Commit

Permalink
docs: add data response chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Aug 31, 2024
1 parent cefb7a8 commit 0ca4106
Show file tree
Hide file tree
Showing 5 changed files with 469 additions and 6 deletions.
11 changes: 7 additions & 4 deletions site/blog/2024-08-29-release-3.17.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tags: [release]
本次 3.17 版本,我们增加了一些新的特性,以及修复了一些问题。



## 定制服务端响应格式

在 3.17 版本中,我们增加了一个新的特性,可以定制服务端的响应的通用格式。
Expand Down Expand Up @@ -76,7 +77,9 @@ return new HttpServerResponse(this.ctx).fail().json('hello world');
}
```

此外,基于这个模式,也同时实现了 SSE 的响应返回。
此外,基于这个模式,也同时实现了 SSE 的响应返回,也有其他的一些数据结构的返回,更多的内容,请参考 [细节文档](/docs/data_response)




## 上传组件
Expand All @@ -91,13 +94,13 @@ return new HttpServerResponse(this.ctx).fail().json('hello world');

其余的使用方式和原有的上传组件一致,

更多细节请访问 [文档](/docs/extensions/busboy)
更多细节请访问 [文档](/docs/extensions/busboy)



## 更多的变化

* 修复了一个健康检查服务丢失 this 的问题
* 参数装饰器增加了一个当前实例的参数
* 修复了一个多语言匹配 key 的问题
* 一些不合理类型定义的调整

以及一大批依赖进行了更新,可以参考我们的 [ChangeLog](https://midwayjs.org/changelog/v3.17.0)
6 changes: 4 additions & 2 deletions site/docs/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,10 @@ export class HomeController {



### 高级响应处理

从 v3.17.0 开始,框架提供了一个新的的 `HttpServerResponse` 来处理返回数据,除了普通的数据之外,还提供了自定义状态模版,文件下载,SSE 等能力支持,具体请查看 [数据响应章节](/docs/data_response)



## 内部重定向
Expand Down Expand Up @@ -1013,8 +1017,6 @@ export class HomeController {

* 3、重定向不会再执行一遍 Web Middleware,不会执行守卫,但是会执行拦截器和参数装饰器





## 全局路由前缀
Expand Down
8 changes: 8 additions & 0 deletions site/docs/cusom_response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 自定义数据响应

在大多数正常的逻辑中,返回数据只需要 `return` 相应的对象。

```typescript

```

Loading

0 comments on commit 0ca4106

Please sign in to comment.