Remove step from sendResponse function

This commit is contained in:
Daniel García Aubert
2018-03-06 16:55:27 +01:00
parent f30f83331f
commit 4762aa0897
+25 -30
View File
@@ -441,8 +441,6 @@ LayergroupController.prototype.bbox = function (previewBackend) {
};
LayergroupController.prototype.sendResponse = function(req, res, body, status, headers) {
var self = this;
req.profiler.done('res');
res.set('Cache-Control', 'public,max-age=31536000');
@@ -458,37 +456,34 @@ LayergroupController.prototype.sendResponse = function(req, res, body, status, h
res.set('Last-Modified', lastUpdated.toUTCString());
var dbName = res.locals.dbname;
step(
function getAffectedTables() {
self.getAffectedTables(res.locals.user, dbName, res.locals.token, this);
},
function sendResponse(err, affectedTables) {
req.profiler.done('affectedTables');
if (err) {
global.logger.warn('ERROR generating cache channel: ' + err);
}
if (!!affectedTables) {
res.set('X-Cache-Channel', affectedTables.getCacheChannel());
self.surrogateKeysCache.tag(res, affectedTables);
}
if (headers) {
res.set(headers);
}
this.getAffectedTables(res.locals.user, dbName, res.locals.token, (err, affectedTables) => {
req.profiler.done('affectedTables');
res.status(status);
if (!Buffer.isBuffer(body) && typeof body === 'object') {
if (req.query && req.query.callback) {
res.jsonp(body);
} else {
res.json(body);
}
} else {
res.send(body);
}
if (err) {
global.logger.warn('ERROR generating cache channel: ' + err);
}
);
if (!!affectedTables) {
res.set('X-Cache-Channel', affectedTables.getCacheChannel());
this.surrogateKeysCache.tag(res, affectedTables);
}
if (headers) {
res.set(headers);
}
res.status(status);
if (!Buffer.isBuffer(body) && typeof body === 'object') {
if (req.query && req.query.callback) {
res.jsonp(body);
} else {
res.json(body);
}
} else {
res.send(body);
}
});
};
LayergroupController.prototype.getAffectedTables = function(user, dbName, layergroupId, callback) {