lib/plugins/accept.js
function acceptParser(accepts) {
    var acceptable = accepts;

    if (!Array.isArray(acceptable)) {
        acceptable = [acceptable];
    }
    assert.arrayOfString(acceptable, 'acceptable');

    acceptable = acceptable.filter(function (a) {
        return (a);
    }).map(function (a) {
            return ((a.indexOf('/') === -1) ? mime.lookup(a) : a);
        }).filter(function (a) {
            return (a);
        });

    var e = new NotAcceptableError('Server accepts: ' + acceptable.join());

    function parseAccept(req, res, next) {
        if (req.accepts(acceptable)) {
            next();
            return;
        }

        res.json(e);
        next(false);
    }

    return (parseAccept);
}
function acceptParser(accepts) {
    var acceptable = accepts;

    if (!Array.isArray(acceptable)) {
        acceptable = [acceptable];
    }
    assert.arrayOfString(acceptable, 'acceptable');

    acceptable = acceptable.filter(function (a) {
        return (a);
    }).map(function (a) {
            return ((a.indexOf('/') === -1) ? mime.lookup(a) : a);
        }).filter(function (a) {
            return (a);
        });

    var e = new NotAcceptableError('Server accepts: ' + acceptable.join());

    function parseAccept(req, res, next) {
        if (req.accepts(acceptable)) {
            next();
            return;
        }

        res.json(e);
        next(false);
    }

    return (parseAccept);
}
function acceptParser ( accepts ) { var acceptable = accepts ; if ( ! Array . isArray ( acceptable ) ) { acceptable = [ acceptable ] ; } assert . arrayOfString ( acceptable , 'acceptable' ) ; acceptable = acceptable . filter ( function ( a ) { return ( a ) ; } ) . map ( function ( a ) { return ( ( a . indexOf ( '/' ) === - 1 ) ? mime . lookup ( a ) : a ) ; } ) . filter ( function ( a ) { return ( a ) ; } ) ; var e = new NotAcceptableError ( 'Server accepts: ' + acceptable . join ( ) ) ; function parseAccept ( req , res , next ) { if ( req . accepts ( acceptable ) ) { next ( ) ; return ; } res . json ( e ) ; next ( false ) ; } return ( parseAccept ) ; }
Returns a plugin that will check the client's Accept header can be handled
by this server.

Note you can get the set of types allowed from a restify server by doing
`server.acceptable`.

@public
@function acceptParser
@throws   {NotAcceptableError}
@param    {String}    accepts array of accept types.
@returns  {Function}             restify handler.
Returns a plugin that will check the client s Accept header can be handled by this server .