0.1.0 • Published 8 years ago
cc-request-id v0.1.0
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-idRunning the tests
$ npm install
$ mochaAPI
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-Idoutputs:
X-Request-Id: 98401c07-e91a-40ca-813e-5407970de407