co-body

request body parsing for co

npm install co-body
27 downloads in the last day
409 downloads in the last week
2 031 downloads in the last month

co-body

Parse request bodies with generators.

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

// application/json
var body = yield parse.json(req);

// application/x-www-form-urlencoded
var body = yield parse.form(req);

// either
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.

// application/json
var body = yield parse.json(this);

// application/x-www-form-urlencoded
var body = yield parse.form(this);

// either
var body = yield parse(this);

License

MIT

npm loves you