Move functionality that sets cache control header to a middleware

This commit is contained in:
Daniel García Aubert
2017-11-14 13:53:42 +01:00
parent a5347c27e3
commit d5c552a03a
+8 -2
View File
@@ -19,14 +19,20 @@ AnalysesController.prototype.register = function(app) {
userMiddleware,
this.prepareContext,
this.catalog.bind(this),
this.setCacheControlHeader(),
this.sendResponse()
);
};
AnalysesController.prototype.setCacheControlHeader = function () {
return function setCacheControlHeaderMiddleware (req, res, next) {
res.set('Cache-Control', 'public,max-age=10,must-revalidate');
next();
};
};
AnalysesController.prototype.sendResponse = function() {
return function sendResponseMiddleware (req, res) {
res.set('Cache-Control', 'public,max-age=10,must-revalidate');
res.status(200);
if (req.query && req.query.callback) {