mirror of
https://github.com/wassname/talk.git
synced 2026-06-28 15:57:48 +08:00
d6f6fbcd9c
* feat: added heroku fixes - Support pulling the request id from the request headers - Add proper cache headers to static files * Update package.json
22 lines
570 B
JavaScript
22 lines
570 B
JavaScript
const { HTTP_X_REQUEST_ID } = require('../config');
|
|
const uuid = require('uuid/v1');
|
|
|
|
// Trace middleware attaches a request id to each incoming request.
|
|
module.exports = HTTP_X_REQUEST_ID
|
|
? (req, res, next) => {
|
|
req.id = req.get(HTTP_X_REQUEST_ID) || uuid();
|
|
|
|
// Add the context ID to the request as an HTTP header.
|
|
res.set('X-Talk-Trace-ID', req.id);
|
|
|
|
next();
|
|
}
|
|
: (req, res, next) => {
|
|
req.id = uuid();
|
|
|
|
// Add the context ID to the request as an HTTP header.
|
|
res.set('X-Talk-Trace-ID', req.id);
|
|
|
|
next();
|
|
};
|