Windshaft-cartodb/lib/api/middlewares/layergroup-id-header.js

19 lines
612 B
JavaScript
Raw Normal View History

'use strict';
2018-03-28 19:41:41 +08:00
module.exports = function setLayergroupIdHeader (templateMaps, useTemplateHash) {
return function setLayergroupIdHeaderMiddleware (req, res, next) {
const { user, template } = res.locals;
const layergroup = res.body;
if (useTemplateHash) {
const templateHash = templateMaps.fingerPrint(template).substring(0, 8);
2018-03-28 19:41:41 +08:00
layergroup.layergroupid = `${user}@${templateHash}@${layergroup.layergroupid}`;
res.locals.templateHash = templateHash;
2018-03-28 19:41:41 +08:00
}
res.set('X-Layergroup-Id', layergroup.layergroupid);
next();
};
};