Windshaft-cartodb/lib/api/middlewares/send-response.js
2019-10-07 09:40:50 +02:00

20 lines
401 B
JavaScript

'use strict';
module.exports = function sendResponse () {
return function sendResponseMiddleware (req, res) {
req.profiler.done('res');
res.status(res.statusCode);
if (Buffer.isBuffer(res.body)) {
return res.send(res.body);
}
if (req.query.callback) {
return res.jsonp(res.body);
}
res.json(res.body);
};
};