1.0.0 • Published 4 years ago

micro-accepts v1.0.0

Weekly downloads
8
License
MIT
Repository
github
Last release
4 years ago

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