Ghost/core/server/web/parent/middleware/request-id.js
Sam Lord 35e51e364b Switch to @tryghost/debug, remove ghost-ignition
no issue
The only pieces of Ghost-Ignition used in Ghost were debug and
logging. Both of these modules have been superceded by the Framework
monorepo, and all usages of Ignition have now been removed, replaced
with @tryghost/debug and @tryghost/logging.
2021-06-15 17:24:22 +01:00

19 lines
433 B
JavaScript

const uuid = require('uuid');
/**
* @TODO: move this middleware to Framework monorepo?
*/
module.exports = (req, res, next) => {
const requestId = req.get('X-Request-ID') || uuid.v4();
// Set a value for internal use
req.requestId = requestId;
// If the header was set on the request, return it on the response
if (req.get('X-Request-ID')) {
res.set('X-Request-ID', requestId);
}
next();
};