Skip to content

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

License

Notifications You must be signed in to change notification settings

call-a3/micro-accepts

Repository files navigation

micro-accepts

NPM Travis Codecov Greenkeeper badge David David Dev

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
  },
})

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published