context.jsdoc 1.0 KB

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