1.0.0 • Published 7 years ago

express-accepts-exact v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

express-accepts-exact

Simple express middleware for filtering routes by exact matches of Accepts header.

NPM Version NPM Downloads

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install express-accepts-exact --save

Example

app.get("/api/custom-download/:file", require("express-accepts-exact")("application/vnd.mydomain.custom"), getFile);
let acceptExact = require("express-accepts-exact");
app.get("/api/custom-download/:file", acceptExact(["application/vnd.mydomain.custom", "plain/text"]), getFile);
let acceptExact = require("express-accepts-exact");
let acceptExperimental = acceptExact("application/vnd.mydomain.experimental");

router.get("/api/file/:file", acceptExperimental, getFileExperimental);
router.get("/api/file/:file", getFile); // Fallback to non experimental version.

API

acceptExact(paths);

paths

Must contain a string or an array of strings.

License

ISC