CartoDB-SQL-API/app/middlewares/content.js
2019-07-26 19:31:28 +02:00

17 lines
566 B
JavaScript

'use strict';
const getContentDisposition = require('../utils/content_disposition');
module.exports = function content () {
return function contentMiddleware (req, res, next) {
const { filename } = res.locals.params;
const { formatter } = req;
const useInline = !req.query.format && !req.body.format && !req.query.filename && !req.body.filename;
res.header("Content-Disposition", getContentDisposition(formatter, filename, useInline));
res.header("Content-Type", formatter.getContentType());
next();
};
};