Split middleware to follow SRP

This commit is contained in:
Daniel García Aubert
2017-11-07 09:50:52 +01:00
parent 693a2e7bee
commit c48e89826d
+11 -1
View File
@@ -79,6 +79,7 @@ MapController.prototype.composeCreateMapMiddleware = function (useTemplate = fal
this.augmentLayergroupData(),
this.getAffectedTables(),
this.setCacheChannel(),
this.setLastModified(),
this.setLastUpdatedTimeToLayergroup(),
this.setCacheControl(),
this.setLayerStats(),
@@ -339,7 +340,6 @@ MapController.prototype.setCacheChannel = function () {
const { affectedTables } = res.locals;
if (req.method === 'GET') {
res.set('Last-Modified', (new Date()).toUTCString());
res.set('X-Cache-Channel', affectedTables.getCacheChannel());
}
@@ -347,6 +347,16 @@ MapController.prototype.setCacheChannel = function () {
};
};
MapController.prototype.setLastModified = function () {
return function setLastModifiedMiddleware (req, res, next) {
if (req.method === 'GET') {
res.set('Last-Modified', (new Date()).toUTCString());
}
next();
};
};
MapController.prototype.setLastUpdatedTimeToLayergroup = function () {
return function setLastUpdatedTimeToLayergroupMiddleware (req, res, next) {
const { affectedTables, layergroup, analysesResults } = res.locals;