8000 GitHub - wentingliu/co-body: Parse request bodies with co
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

wentingliu/co-body

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

co-body

Parse request bodies with generators inspired by Raynos/body.

Installation

$ npm install co-body

Options

62D5

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);

// explicit limit
var body = yield parse.json(req, { limit: '10kb' });

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

About

Parse request bodies with co

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%
0