From c48e89826d117225050f6f9dafb8cfc29ab45d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 7 Nov 2017 09:50:52 +0100 Subject: [PATCH] Split middleware to follow SRP --- lib/cartodb/controllers/map.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/cartodb/controllers/map.js b/lib/cartodb/controllers/map.js index 1510dfc2..4c2d6764 100644 --- a/lib/cartodb/controllers/map.js +++ b/lib/cartodb/controllers/map.js @@ -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;