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) {
self.sendError(req, res, err, 'GET ATTRIBUTES');
} 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.' + formatStat + '.error');
} 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.' + formatStat + '.success');
}
@ -211,14 +211,14 @@ LayergroupController.prototype.staticMap = function(req, res, width, height, zoo
if (err) {
self.sendError(req, res, err, 'STATIC_MAP');
} else {
res.setHeader('Content-Type', headers['Content-Type'] || 'image/' + format);
self.sendResponse(req, res, [image, 200]);
res.set('Content-Type', headers['Content-Type'] || 'image/' + format);
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;
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());
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) {
self.sendError(req, res, err, 'ANONYMOUS LAYERGROUP');
} else {
res.header('X-Layergroup-Id', layergroup.layergroupid);
self.send(req, res, [layergroup, 200]);
res.set('X-Layergroup-Id', layergroup.layergroupid);
self.send(req, res, layergroup, 200);
}
}
);
@ -226,7 +226,7 @@ MapController.prototype.instantiateTemplate = function(req, res, prepareParamsFn
res.set('X-Layergroup-Id', layergroup.layergroupid);
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.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*/){
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){
if (err) {
controller.sendError(req, res, err, description);
} 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) {
res.send(WELCOME_MSG, 200);
res.status(200).send(WELCOME_MSG);
};
ServerInfoController.prototype.version = function(req, res) {
res.send(versions, 200);
res.status(200).send(versions);
};
ServerInfoController.prototype.health = function(req, res) {
@ -47,10 +47,10 @@ ServerInfoController.prototype.health = function(req, res) {
if (err) {
response.err = err.message;
}
res.send(response, ok ? 200 : 503);
res.status(ok ? 200 : 503).send(response);
});
} else {
res.send({enabled: false, ok: true}, 200);
res.status(200).send({enabled: false, ok: true});
}
};