mirror of
https://github.com/wassname/talk.git
synced 2026-06-28 17:19:36 +08:00
12 lines
271 B
JavaScript
12 lines
271 B
JavaScript
const uuid = require('uuid/v1');
|
|
|
|
// Trace middleware attaches a request id to each incoming request.
|
|
module.exports = (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();
|
|
};
|