Call send with correct params

This commit is contained in:
Raul Ochoa 2015-09-17 02:05:25 +02:00
parent feabb20748
commit a4ba21f9db
5 changed files with 18 additions and 18 deletions

View File

@ -77,7 +77,7 @@ LayergroupController.prototype.attributes = function(req, res) {
if (err) { if (err) {
self.sendError(req, res, err, 'GET ATTRIBUTES'); self.sendError(req, res, err, 'GET ATTRIBUTES');
} else { } else {
self.sendResponse(req, res, [tile, 200]); self.sendResponse(req, res, tile, 200);
} }
} }
); );
@ -159,7 +159,7 @@ LayergroupController.prototype.finalizeGetTileOrGrid = function(err, req, res, t
global.statsClient.increment('windshaft.tiles.error'); global.statsClient.increment('windshaft.tiles.error');
global.statsClient.increment('windshaft.tiles.' + formatStat + '.error'); global.statsClient.increment('windshaft.tiles.' + formatStat + '.error');
} else { } else {
this.sendResponse(req, res, [tile, headers, 200]); this.sendResponse(req, res, tile, 200, headers);
global.statsClient.increment('windshaft.tiles.success'); global.statsClient.increment('windshaft.tiles.success');
global.statsClient.increment('windshaft.tiles.' + formatStat + '.success'); global.statsClient.increment('windshaft.tiles.' + formatStat + '.success');
} }
@ -211,14 +211,14 @@ LayergroupController.prototype.staticMap = function(req, res, width, height, zoo
if (err) { if (err) {
self.sendError(req, res, err, 'STATIC_MAP'); self.sendError(req, res, err, 'STATIC_MAP');
} else { } else {
res.setHeader('Content-Type', headers['Content-Type'] || 'image/' + format); res.set('Content-Type', headers['Content-Type'] || 'image/' + format);
self.sendResponse(req, res, [image, 200]); self.sendResponse(req, res, image, 200);
} }
} }
); );
}; };
LayergroupController.prototype.sendResponse = function(req, res, args) { LayergroupController.prototype.sendResponse = function(req, res, body, status, headers) {
var self = this; var self = this;
res.set('Cache-Control', 'public,max-age=31536000'); res.set('Cache-Control', 'public,max-age=31536000');
@ -248,7 +248,7 @@ LayergroupController.prototype.sendResponse = function(req, res, args) {
res.set('X-Cache-Channel', tablesCacheEntry.getCacheChannel()); res.set('X-Cache-Channel', tablesCacheEntry.getCacheChannel());
self.surrogateKeysCache.tag(res, tablesCacheEntry); self.surrogateKeysCache.tag(res, tablesCacheEntry);
} }
self.send(req, res, args); self.send(req, res, body, status, headers);
} }
); );

View File

@ -166,8 +166,8 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
if (err) { if (err) {
self.sendError(req, res, err, 'ANONYMOUS LAYERGROUP'); self.sendError(req, res, err, 'ANONYMOUS LAYERGROUP');
} else { } else {
res.header('X-Layergroup-Id', layergroup.layergroupid); res.set('X-Layergroup-Id', layergroup.layergroupid);
self.send(req, res, [layergroup, 200]); self.send(req, res, layergroup, 200);
} }
} }
); );
@ -226,7 +226,7 @@ MapController.prototype.instantiateTemplate = function(req, res, prepareParamsFn
res.set('X-Layergroup-Id', layergroup.layergroupid); res.set('X-Layergroup-Id', layergroup.layergroupid);
self.surrogateKeysCache.tag(res, new NamedMapsCacheEntry(cdbuser, mapConfigProvider.getTemplateName())); self.surrogateKeysCache.tag(res, new NamedMapsCacheEntry(cdbuser, mapConfigProvider.getTemplateName()));
self.send(req, res, [layergroup, 200]); self.send(req, res, layergroup, 200);
} }
} }
); );

View File

@ -68,7 +68,7 @@ NamedMapsController.prototype.sendResponse = function(req, res, resource, header
self.surrogateKeysCache.tag(res, tablesCacheEntry); self.surrogateKeysCache.tag(res, tablesCacheEntry);
} }
} }
self.send(req, res, [resource, 200]); self.send(req, res, resource, 200);
} }
); );
}; };

View File

@ -144,9 +144,9 @@ NamedMapsAdminController.prototype.destroy = function(req, res) {
}, },
function prepareResponse(err/*, tpl_val*/){ function prepareResponse(err/*, tpl_val*/){
assert.ifError(err); assert.ifError(err);
return { status: 'ok' }; return '';
}, },
finishFn(self, req, res, 'DELETE TEMPLATE', ['', 204]) finishFn(self, req, res, 'DELETE TEMPLATE', 204)
); );
}; };
@ -176,12 +176,12 @@ NamedMapsAdminController.prototype.list = function(req, res) {
); );
}; };
function finishFn(controller, req, res, description, okResponse) { function finishFn(controller, req, res, description, status) {
return function finish(err, response){ return function finish(err, response){
if (err) { if (err) {
controller.sendError(req, res, err, description); controller.sendError(req, res, err, description);
} else { } else {
controller.send(req, res, okResponse || [response, 200]); controller.send(req, res, response, status || 200);
} }
}; };
} }

View File

@ -27,11 +27,11 @@ ServerInfoController.prototype.register = function(app) {
}; };
ServerInfoController.prototype.welcome = function(req, res) { ServerInfoController.prototype.welcome = function(req, res) {
res.send(WELCOME_MSG, 200); res.status(200).send(WELCOME_MSG);
}; };
ServerInfoController.prototype.version = function(req, res) { ServerInfoController.prototype.version = function(req, res) {
res.send(versions, 200); res.status(200).send(versions);
}; };
ServerInfoController.prototype.health = function(req, res) { ServerInfoController.prototype.health = function(req, res) {
@ -47,10 +47,10 @@ ServerInfoController.prototype.health = function(req, res) {
if (err) { if (err) {
response.err = err.message; response.err = err.message;
} }
res.send(response, ok ? 200 : 503); res.status(ok ? 200 : 503).send(response);
}); });
} else { } else {
res.send({enabled: false, ok: true}, 200); res.status(200).send({enabled: false, ok: true});
} }
}; };