jsonapi-headers
v2.0.0
Published
Provide a middleware to validate JSON API headers on a request
Downloads
33
Readme
JSON API Headers
This module validates incoming headers and adds outgoing headers for JSON API based systems. In additon to basic content negotiation this module supports extension negotiation.
Usage
// Without extension support.
app.use(require('jsonapi-headers')());
// OR With extension support.
app.use(require('jsonapi-headers')(['batch', 'jsonpatch']));The resulting middleware will validate Accept and Content-Type headers
as defined by JSON API and will call next with an error if the headers are
invalid (either a 406 or 415 depending on what's wrong).
If there are no validation problems, the Content-Type of the response will
be appropriately assigned, e.g.
application/vnd.api+json; ext=bulk; supported-ext="batch,jsonpatch"
Additionally, any extensions that the request is supporting will be added as
an array to req.ext.
