Skip to content

WORMSS/express-accepts-exact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-accepts-exact

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

This is useful for having routes that behave like github's api with experimental features that require one of the accepts be application/vnd.github.pegasus allowing clients to opt into possible breaking changes.

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

Only use this route if accepts header contains application/vnd.mydomain.experimental.

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.

Only use this route if accepts header contains application/vnd.mydomain.custom or plain/text

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

API

acceptExact(paths);

paths

Must contain a string or an array of strings.

License

ISC

About

Express middleware to exactly match a value in Accepts header.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published