| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1× 1× 3× 3× 3× 3× 3× 1× 1× | /**
* A middleware that sets a default character set in the Content-Type
* header of the response if none is already specified.
*/
const {isNil} = require("ramda");
function charset(app, defaultCharset) {
defaultCharset = defaultCharset || "utf-8";
return function (conn) {
return conn.call(app).then(function () {
const response = conn.response;
if (response.contentType && isNil(response.charset)) {
response.charset = defaultCharset;
}
});
};
}
module.exports = charset;
|