all files / modules/extensions/ accept.js

88.89% Statements 8/9
50% Branches 1/2
66.67% Functions 2/3
88.89% Lines 8/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                                                
const d = require("describe-property");
const Accept = require("../headers/Accept");
 
module.exports = function (mach) {
    Object.defineProperties(mach.Connection.prototype, {
 
    /**
     * Returns true if the request indicates that the client accepts
     * the given media type.
     */
        accepts: d(function (mediaType) {
            return this.request.accepts(mediaType);
        })
 
    });
 
    Object.defineProperties(mach.Message.prototype, {
 
    /**
     * Returns true if the client accepts the given media type.
     */
        accepts: d(function (mediaType) {
            Eif (!this._acceptHeader) {
                this._acceptHeader = new Accept(this.headers.Accept);
            }
 
            return this._acceptHeader.accepts(mediaType);
        })
 
    });
};