333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * 继承 koa 的 Context
 * @class Context
 * @see http://koajs.com/#context
 */
 
/**
 * 实现页面跳转
 * @see Response#redirect
 * @method Context#redirect
 * @param {String} url 需要跳转的地址
 */
 
/**
 * 开启 {@link Rest} 功能后,将会有 `this.params` 对象
 * @member {Object} Context#params
 * @example
 * ##### ctx.params.id {String}
 *
 * 资源 id,如 `GET /api/users/1` => `'1'`
 *
 * ##### ctx.params.ids {Array<String>}
 *
 * 一组资源 id,如 `GET /api/users/1,2,3` => `['1', '2', '3']`
 *
 * ##### ctx.params.fields {Array<String>}
 *
 * 期待返回的资源字段,如 `GET /api/users/1?fields=name,title` => `['name', 'title']`.
 * 即使应用 Controller 实现返回了全部字段,[REST] 处理器会根据 `fields` 筛选只需要的字段。
 *
 * ##### ctx.params.data {Object}
 *
 * 请求数据对象
 *
 * ##### ctx.params.page {Number}
 *
 * 分页码,如 `GET /api/users?page=10` => `10`
 *
 * ##### ctx.params.per_page {Number}
 *
 * 每页资源数目,如 `GET /api/users?per_page=20` => `20`
 */