lib/middleware/stack.js
function callRequestMiddleware(arg2, arg3) {
        i += 1;
        if (i < self.middlewares.length) {
            var next = self.middlewares[i].request;
            if (typeof next === 'function') {
                next(req, arg2, arg3, callRequestMiddleware);
            } else {
                // skip this middleware if it doesn't implement request
                callRequestMiddleware(arg2, arg3);
            }
        } else {
            handler(req, arg2, arg3, callResponseMiddleware);
        }
    }
function callRequestMiddleware(arg2, arg3) {
        i += 1;
        if (i < self.middlewares.length) {
            var next = self.middlewares[i].request;
            if (typeof next === 'function') {
                next(req, arg2, arg3, callRequestMiddleware);
            } else {
                // skip this middleware if it doesn't implement request
                callRequestMiddleware(arg2, arg3);
            }
        } else {
            handler(req, arg2, arg3, callResponseMiddleware);
        }
    }
function callRequestMiddleware ( arg2 , arg3 ) { i += 1 ; if ( i < self . middlewares . length ) { var next = self . middlewares [ i ] . request ; if ( typeof next === 'function' ) { next ( req , arg2 , arg3 , callRequestMiddleware ) ; } else { // skip this middleware if it doesn't implement request callRequestMiddleware ( arg2 , arg3 ) ; } } else { handler ( req , arg2 , arg3 , callResponseMiddleware ) ; } }
This function calls the next request middleware in the stack or, if there is none left, calls the first response middleware, in reverse. It also skips any middlewares that don't implement the request method.
This function calls the next request middleware in the stack or if there is none left calls the first response middleware in reverse . It also skips any middlewares that don t implement the request method .