function $5f613ef21b2f8d72$var$finalhandler(req, res, options) {
    var opts = options || {
    };
    // get environment
    var env = opts.env || process.env.NODE_ENV || 'development';
    // get error callback
    var onerror = opts.onerror;
    return function(err) {
        var headers;
        var msg;
        var status;
        // ignore 404 on in-flight response
        if (!err && $5f613ef21b2f8d72$var$headersSent(res)) {
            $5f613ef21b2f8d72$var$debug('cannot 404 after headers sent');
            return;
        }
        // unhandled error
        if (err) {
            // respect status code from error
            status = $5f613ef21b2f8d72$var$getErrorStatusCode(err);
            if (status === undefined) // fallback to status code on response
            status = $5f613ef21b2f8d72$var$getResponseStatusCode(res);
            else // respect headers from error
            headers = $5f613ef21b2f8d72$var$getErrorHeaders(err);
            // get error message
            msg = $5f613ef21b2f8d72$var$getErrorMessage(err, status, env);
        } else {
            // not found
            status = 404;
            msg = 'Cannot ' + req.method + ' ' + $80ab93e5d866214f$exports($5f613ef21b2f8d72$var$getResourceName(req));
        }
        $5f613ef21b2f8d72$var$debug('default %s', status);
        // schedule onerror callback
        if (err && onerror) $5f613ef21b2f8d72$var$defer(onerror, err, req, res);
        // cannot actually respond
        if ($5f613ef21b2f8d72$var$headersSent(res)) {
            $5f613ef21b2f8d72$var$debug('cannot %d after headers sent', status);
            req.socket.destroy();
            return;
        }
        // send response
        $5f613ef21b2f8d72$var$send(req, res, status, headers, msg);
    };
}
/**
 * Create a function to handle the final response.
 *
 * @param {Request} req
 * @param {Response} res
 * @param {Object} [options]
 * @return {Function}
 * @public
 */
Create a function to handle the final response.
Create a function to handle the final response .
function $5f613ef21b2f8d72$var$finalhandler(req, res, options) {
    var opts = options || {
    };
    var env = opts.env || process.env.NODE_ENV || 'development';
    var onerror = opts.onerror;
    return function(err) {
        var headers;
        var msg;
        var status;
        if (!err && $5f613ef21b2f8d72$var$headersSent(res)) {
            $5f613ef21b2f8d72$var$debug('cannot 404 after headers sent');
            return;
        }
        if (err) {
            status = $5f613ef21b2f8d72$var$getErrorStatusCode(err);
            if (status === undefined) 
            status = $5f613ef21b2f8d72$var$getResponseStatusCode(res);
            else 
            headers = $5f613ef21b2f8d72$var$getErrorHeaders(err);
            msg = $5f613ef21b2f8d72$var$getErrorMessage(err, status, env);
        } else {
            status = 404;
            msg = 'Cannot ' + req.method + ' ' + $80ab93e5d866214f$exports($5f613ef21b2f8d72$var$getResourceName(req));
        }
        $5f613ef21b2f8d72$var$debug('default %s', status);
        if (err && onerror) $5f613ef21b2f8d72$var$defer(onerror, err, req, res);
        if ($5f613ef21b2f8d72$var$headersSent(res)) {
            $5f613ef21b2f8d72$var$debug('cannot %d after headers sent', status);
            req.socket.destroy();
            return;
        }
        $5f613ef21b2f8d72$var$send(req, res, status, headers, msg);
    };
}
function $5f613ef21b2f8d72$var$finalhandler ( req , res , options ) { var opts = options || { } ; var env = opts . env || process . env . NODE_ENV || 'development' ; var onerror = opts . onerror ; return function ( err ) { var headers ; var msg ; var status ; if ( ! err && $5f613ef21b2f8d72$var$headersSent ( res ) ) { $5f613ef21b2f8d72$var$debug ( 'cannot 404 after headers sent' ) ; return ; } if ( err ) { status = $5f613ef21b2f8d72$var$getErrorStatusCode ( err ) ; if ( status === undefined ) status = $5f613ef21b2f8d72$var$getResponseStatusCode ( res ) ; else headers = $5f613ef21b2f8d72$var$getErrorHeaders ( err ) ; msg = $5f613ef21b2f8d72$var$getErrorMessage ( err , status , env ) ; } else { status = 404 ; msg = 'Cannot ' + req . method + ' ' + $80ab93e5d866214f$exports ( $5f613ef21b2f8d72$var$getResourceName ( req ) ) ; } $5f613ef21b2f8d72$var$debug ( 'default %s' , status ) ; if ( err && onerror ) $5f613ef21b2f8d72$var$defer ( onerror , err , req , res ) ; if ( $5f613ef21b2f8d72$var$headersSent ( res ) ) { $5f613ef21b2f8d72$var$debug ( 'cannot %d after headers sent' , status ) ; req . socket . destroy ( ) ; return ; } $5f613ef21b2f8d72$var$send ( req , res , status , headers , msg ) ; } ; }
Create a function to handle the final response.
Create a function to handle the final response .
// get environment // get error callback // ignore 404 on in-flight response // unhandled error // respect status code from error // fallback to status code on response // respect headers from error // get error message // not found // schedule onerror callback // cannot actually respond // send response