egg/lib/jsdoc/context.jsdoc
2017-06-09 19:37:17 +08:00

43 lines
1.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 继承 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`
*/