cc-request-id
v0.1.0
Published
Express.js request-id middleware.
Downloads
11
Maintainers
Readme
request-id
Express.js request-id middleware.
Allows you to identify client requests within non-sequential logs by adding a response header of X-Request-Id
.
Allows setting value via query parameter or request header.
Installation
$ npm install cc-request-id
Running the tests
$ npm install
$ mocha
API
var requestId = require('cc-request-id')
requestId(options)
Create new request-id middleware.
options
See request-id options. Exception: Default value generator function: uuid-1345.v4fast
Example
var express = require('express')
var app = express()
var requestId = require('cc-request-id')
var bodyParser = require('body-parser')
app.use(requestId())
app.use(bodyParser())
app.get('/test', function (req, res, next) {
res.send('OK')
})
app.listen(8080)
test it:
curl http://localhost:8080/test -I | grep X-Request-Id
outputs:
X-Request-Id: 98401c07-e91a-40ca-813e-5407970de407