micro-accepts

A decorator for use with micro to handle requests differently depending on content negotiation

MIT License

Downloads
9
Stars
0
Committers
3

micro-accepts

micro decorator to vary request handling based on the Accept header of the request.

Installing

# npm
npm install -s micro-accepts

# yarn
yarn add micro-accepts

Usage

import accepts from 'micro-accepts'

export default accepts({
  async json(req, res) {
    // this method will handle requests that prefer json
  },
  async ['application/xml+custom'](req, res) {
    // this method will handle requests that prefer application/xml+custom
  },
  async text(req, res) {
    // this method will handle requests that accept text. This is also the default if no more specific types are accepted
  },
})
Package Rankings
Top 22.37% on Npmjs.org
Badges
Extracted from project README
NPM Travis Codecov Greenkeeper badge David David Dev