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).

Readme

Keywords

none

Package Sidebar

Install

npm i header-parser

Weekly Downloads

13

Version

1.0.0

License

MIT

Last publish

Collaborators

  • blainsmith