【文件属性】:
文件名称:小程序后端 egg 框架开发记录
文件大小:53KB
文件格式:PDF
更新时间:2021-03-29 16:52:50
小,程序,后端,egg,框架,开发,记录,内置,对象,
内置对象
Request & Response
可以在 Context 的实例上获取到当前请求的 Request( ctx.request ) 和 Response( ctx.response ) 实例。
ctx.response.body= 和 ctx.body= 是等价的。
[!] 需要注意的是,获取 POST 的 body 应该使用 ctx.request.body ,而不是 ctx.body
Controller
框架提供了一个 Controller 基类,并推荐所有的 Controller 都继承于该基类实现。这个 Controller 基类有下列属性:
ctx - 当前请求的 Co