| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1× 1× 1× 1× 1× 1× 1× 1× | /**
* A middleware that sets a default Content-Type header in case one hasn't
* already been set in a downstream app.
*/
function contentType(app, defaultType) {
defaultType = defaultType || "text/html";
return function (conn) {
return conn.call(app).then(function () {
const headers = conn.response.headers;
Eif (!headers["Content-Type"]) {
headers["Content-Type"] = defaultType;
}
});
};
}
module.exports = contentType;
|