npm's personal messenger
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

header-parser

1.0.0 • Public • Published

Header Parser Middleware

Some headers can be query-string encoded so this middleware makes 2 methods available to access parsed versions of those headers.

Usage

> npm install header-parser
var headerParser = require('header-parser');
var app = express();
 
app.use(headerParser);

req.getParsed(field)

Returns the specified HTTP request header field (case-insensitive match) that is encoded in query-string format as JSON.

req.get('X-Custom-Header');
// => "foo=bar&baz=My%20Val"
 
req.getParsed('X-Custom-Header');
/* =>
{
    foo: 'bar',
    baz: 'My Val'
}
*/

Aliased for req.headerParsed(field).

Keywords

none

install

npm i header-parser

Downloadsweekly downloads

36

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability