middleware.js 258 B

1234567891011
  1. module.exports = () => {
  2. function render(json) {
  3. this.set("Content-Type", "application/json")
  4. this.body = JSON.stringify(json)
  5. // console.log(this.body)
  6. }
  7. return async (ctx, next) => {
  8. ctx.send = render.bind(ctx)
  9. await next()
  10. }
  11. }