koajs / bodyparser

Koa body parsing middleware
MIT License
1.31k stars 116 forks source link

passing the returning value of next middleware through #83

Closed xfoxfu closed 7 years ago

xfoxfu commented 7 years ago

I think it is better to offer a option of passing through the returning value of the next middleware, as most applications may wrap a global error handler before all the middlewares. By providing such feature, we can do:

koa.use(async (ctx,next) => {
  console.log("middleware returned",await next());
});
koa.use(bodyParser());

Which adds a lot flexibility to applications.

dead-horse commented 7 years ago

you can read request body from ctx.request.body