express-request-id
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -10,7 +10,8 @@ 'use strict'; | ||
options.headerName = options.headerName || 'X-Request-Id'; | ||
options.attributeName = options.attributeName || 'id'; | ||
return function (req, res, next) { | ||
req.id = req.header(options.headerName) || uuid[options.uuidVersion](options, options.buffer, options.offset); | ||
req[options.attributeName] = req.header(options.headerName) || uuid[options.uuidVersion](options, options.buffer, options.offset); | ||
if (options.setHeader) { | ||
res.setHeader(options.headerName, req.id); | ||
res.setHeader(options.headerName, req[options.attributeName]); | ||
} | ||
@@ -17,0 +18,0 @@ next(); |
{ | ||
"name": "express-request-id", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Generate UUID for request and add it to headers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -36,2 +36,3 @@ # express-request-id [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] | ||
* `headerName` - string, indicates the header name to use (defaults to `X-Request-Id`). | ||
* `attributeName` - string, indicates the attribute name used for the identifier on the request object (defaults to `id`) | ||
@@ -38,0 +39,0 @@ This options fields are passed to node-uuid functions directly: |
4249
16
52