Set headers with set method

This commit is contained in:
Raul Ochoa
2015-09-17 02:03:09 +02:00
parent beabe48aec
commit ef86bacf7f
7 changed files with 29 additions and 28 deletions
+11 -10
View File
@@ -149,18 +149,18 @@ BaseController.prototype.req2params = function(req, callback){
};
// jshint maxcomplexity:6
BaseController.prototype.send = function(req, res, args) {
if (global.environment && global.environment.api_hostname) {
res.header('X-Served-By-Host', global.environment.api_hostname);
}
if (req.params && req.params.dbhost) {
res.header('X-Served-By-DB-Host', req.params.dbhost);
// jshint maxcomplexity:9
BaseController.prototype.send = function(req, res, body, status, headers) {
if (req.params.dbhost) {
res.set('X-Served-By-DB-Host', req.params.dbhost);
}
if (req.profiler) {
res.header('X-Tiler-Profiler', req.profiler.toJSONString());
res.set('X-Tiler-Profiler', req.profiler.toJSONString());
}
if (headers) {
res.set(headers);
}
res.send.apply(res, args);
@@ -175,6 +175,7 @@ BaseController.prototype.send = function(req, res, args) {
}
}
};
// jshint maxcomplexity:6
BaseController.prototype.sendError = function(req, res, err, label) {
label = label || 'UNKNOWN';
@@ -204,7 +205,7 @@ BaseController.prototype.sendError = function(req, res, err, label) {
var errorResponseBody = { errors: [message] };
this.send(req, res, [errorResponseBody, statusCode]);
this.send(req, res, errorResponseBody, statusCode);
};
function findStatusCode(err) {