co-body
Parse request bodies with generators inspired by Raynos/body.
Installation
$ npm install co-body
Options
Available via raw-body:
limit
number or string representing the request size limit (1mb for json and 56kb for form-urlencoded)
Example
var body = yield parse.json(req);
var body = yield parse.json(req, { limit: '10kb' });
var body = yield parse.form(req);
var body = yield parse(req);
Koa
This lib also supports ctx.req
in Koa (or other libraries),
so that you may simply use this
instead of this.req
.
var body = yield parse.json(this);
var body = yield parse.form(this);
var body = yield parse(this);
License
MIT