Windshaft-cartodb/lib/api/middlewares/send-response.js

20 lines
401 B
JavaScript
Raw Normal View History

'use strict';
2018-03-20 02:48:14 +08:00
module.exports = function sendResponse () {
return function sendResponseMiddleware (req, res) {
req.profiler.done('res');
res.status(res.statusCode);
2018-03-20 02:48:14 +08:00
if (Buffer.isBuffer(res.body)) {
return res.send(res.body);
}
if (req.query.callback) {
return res.jsonp(res.body);
}
res.json(res.body);
};
};