micro-accepts
v1.0.0
Published
A utility package which allows you to clean up before node exits
Downloads
1
Readme
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
},
})