- Logs to stdout, disabled while testing - Change log calls signature when needed - Use development version of camshaft - Removes unused log cofiguration - Bind request id to log req/res - Log req at the begining of the cycle and res at the end
27 lines
684 B
JavaScript
27 lines
684 B
JavaScript
'use strict';
|
|
|
|
module.exports = function setCacheChannelHeader () {
|
|
return function setCacheChannelHeaderMiddleware (req, res, next) {
|
|
if (req.method !== 'GET') {
|
|
return next();
|
|
}
|
|
|
|
const { mapConfigProvider } = res.locals;
|
|
|
|
mapConfigProvider.getAffectedTables((err, affectedTables) => {
|
|
if (err) {
|
|
global.logger.warn(err, 'ERROR generating Cache Channel Header');
|
|
return next();
|
|
}
|
|
|
|
if (!affectedTables) {
|
|
return next();
|
|
}
|
|
|
|
res.set('X-Cache-Channel', affectedTables.getCacheChannel());
|
|
|
|
next();
|
|
});
|
|
};
|
|
};
|