yorkie / koa-saccept

Semantic HTTP accept middleware for koajs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

koa-saccept

Semantic HTTP accept middleware for koajs

Installation

$ npm install koa-saccept

Usage

var saccept = require('koa-saccept');
var app = require('express')();

app.use(saccept());
app.get('/', function * () {
  // accept: application/vnd.xxx.v1.6.0+json will be accepted here
  // accept: application/vnd.xxx.v1.6.0+xml will be rejected here
  // accept: application/vnd.xxx.v1.5.0+json will be rejected here
  this.request.accept('1.6.*', 'application/json');
});

Ref

License

MIT

About

Semantic HTTP accept middleware for koajs


Languages

Language:JavaScript 100.0%