Centralize common headers, this will help up to move biz metrics out of the process
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
const setCommonHeaders = require('../../utils/common-headers');
|
||||
|
||||
module.exports = function sendResponse () {
|
||||
return function sendResponseMiddleware (req, res, next) {
|
||||
res.status(res.statusCode);
|
||||
setCommonHeaders(req, res, () => {
|
||||
res.status(res.statusCode);
|
||||
|
||||
if (Buffer.isBuffer(res.body)) {
|
||||
res.send(res.body);
|
||||
if (Buffer.isBuffer(res.body)) {
|
||||
res.send(res.body);
|
||||
return next();
|
||||
}
|
||||
|
||||
if (req.query.callback) {
|
||||
res.jsonp(res.body);
|
||||
return next();
|
||||
}
|
||||
|
||||
res.json(res.body);
|
||||
return next();
|
||||
}
|
||||
|
||||
if (req.query.callback) {
|
||||
res.jsonp(res.body);
|
||||
return next();
|
||||
}
|
||||
|
||||
res.json(res.body);
|
||||
return next();
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user