Parse hal+json body using halson and co-body.
$ npm install hal-body
Available via raw-body:
limit
number or string representing the request size limit (1mb for json)
var parseHal = require('hal-body');
// application/hal+json
var resource = yield parseHal(req);
console.log(resource.title));
console.log(resource.getLink('self'));
This lib also supports ctx.req
in Koa (or other libraries),
so that you may simply use this
instead of this.req
.
var parseHal = require('hal-body');
// application/hal+json
var resource = yield parseHal(this);
console.log(resource.title);
console.log(resource.getLink('self'));
MIT