all files / modules/middleware/ contentType.js

100% Statements 8/8
50% Branches 2/4
100% Functions 3/3
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20                       
/**
 * 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;