Adds a middleware object used to process all incoming requests against the API
512727
def add_middleware(self, middleware):
        """"""
        if self.middleware is None:
            self._middleware = []
        self.middleware.append(middleware)
474320
function middleware(req, res, next) {
  req.security.csrf.exclude = true;
  next();
}
1199517
function(middlewares, response, callback) {
        var that = this;
        var middleware = middlewares.shift();
        if (!middleware) {
            return callback(null, response);
        }
        var middleware_callback = function(retVal) {
            /**
             * got an error
             * break middleware chain and callback
             */
            if (retVal && retVal instanceof Error) {
                return callback(retVal, response);
            }
            /**
             * got a response object
             * break middleware chain and bypass request
             */
            if (retVal && typeof retVal == 'object') {
                return callback(null, retVal);
            }
            that._callResponseMiddlewares(middlewares, response, callback);
        };
        try {
            middleware(response, middleware_callback);
        } catch (e) {
            callback(e, response);
        }
    }
871273
function () {
    var middlewares = Array.prototype.slice.apply(arguments)
      , req = middlewares.splice(0, 1)
      , next = middlewares.pop()
    
    // Check other middlewares for client objects. If we find one, merge
    // it and ours together.
    for (var i = 0; i < middlewares.length; i++) {
      var middleware_obj = middlewares[i]
      if (middleware_obj.type == 'client') {
        utils.merge(middlewares[i], hist_obj)
        return undefined
      }
    }
    
    // If we get this far, no other middlewares match client type. So pass
    // our middleware object.
    next({'history': hist_obj})
    return undefined
  }
820060
function (method, endpoint, routerMiddelware) {
		var self = this;

		if (typeof routerMiddelware == 'object'){
			this.app[method](endpoint, function (req, res, next) {
				var middlewareFunction = []
				routerMiddelware.forEach(function (m) {
					middlewareFunction.push(function (cb) {
						self.__exec__middlewares(m, req, res, cb);
					});
				});

				async.waterfall(middlewareFunction);
			});
		} else {
			this.app[method](endpoint, function (req, res, next) {
				self.__exec__middleware(routerMiddelware)(req, res, next);
			});
		}
	}
972759
def middleware(self, args):
        
        if self.url[(len(self.url) - 1)] == (self.url_, self.controller, dict(method=self.method, request_type=self.request_type, middleware=None)):
            self.url.pop()
        self.url.append((self.url_, self.controller, dict(method=self.method, request_type=self.request_type, middleware=args)))
        return self
284992
def dispatch(self, request, *args, **kwargs):
        """"""
        self.request = DownstreamRequest(request)
        self.args = args
        self.kwargs = kwargs

        self._verify_config()

        self.middleware = MiddlewareSet(self.proxy_middleware)

        return self.proxy()
221299
protected function registerMiddleware() {
    $middleware = $this->app['config']['app.middleware'];

    foreach ($middleware as $class_name) {
      $filter = app($class_name);
      if ($filter instanceof BeforeInterface) {
        array_push($this->before, $filter);
      }
      if ($filter instanceof AfterInterface) {
        array_push($this->after, $filter);
      }
    }
  }
834361
def setup(self, middleware):
        
        if not isinstance(middleware, BaseMiddleware):
            raise TypeError(f"`middleware` must be an instance of BaseMiddleware, not {type(middleware)}")
        if middleware.is_configured():
            raise ValueError('That middleware is already used!')

        self.applications.append(middleware)
        middleware.setup(self)
        log.debug(f"Loaded middleware '{middleware.__class__.__name__}'")
        return middleware
441258
def _add_route(self, method, path, middleware=None):
        """"""
        if middleware is not None:
            self.add(method, path, middleware)
            return self
        else:
            # return a lambda that will return the 'func' argument
            return lambda func: (
                self.add(method, path, func),
                func
            )[1]
680497
def reqresp_middleware(api=None):
    """"""
    def decorator(middleware_generator):
        apply_to_api = hug.API(api) if api else hug.api.from_object(middleware_generator)

        class MiddlewareRouter(object):
            __slots__ = ('gen', )

            def process_request(self, request, response):
                self.gen = middleware_generator(request)
                return self.gen.__next__()

            def process_response(self, request, response, resource, req_succeeded):
                return self.gen.send((response, resource))

        apply_to_api.http.add_middleware(MiddlewareRouter())
        return middleware_generator
    return decorator
1143684
function middlewares() {
        app.middlewares = {}
        const basePath = path.join(app.root, '/middlewares')
        let middlewares = app.config.get('express').middlewares
        if (middlewares && Array.isArray(middlewares) && middlewares.length) {
            for (let m of middlewares) {
                let middleware = require(path.join(basePath, m.dest))(app)
                app.middlewares[m.dest.toLowerCase()] = middleware

                if (middleware.length == 4) { //error handler
                    errorHandlers.push(middleware)
                    continue
                }

                if (m.src)
                    server.use(m.src, wrapper(middleware))
                else
                    server.use(wrapper(middleware))
            }
            if (middlewares.length)
                app.drivers.logger.success('Middleware', 'initialized')
        }
    }
302302
def construct_fixture_middleware(fixtures):
    
    def fixture_middleware(make_request, web3):
        def middleware(method, params):
            if method in fixtures:
                result = fixtures[method]
                return {'result': result}
            else:
                return make_request(method, params)
        return middleware
    return fixture_middleware
622673
function(){
                if (executionChainDone){
                    console.log('execution done !!!')
                    return;
                }
                if (i >= _middleware.length){

                    fn(request,response);
                }
                else{
                    mf = _middleware[i];
                    i++;
                    mf(request,response,next);
                }
            }
707866
private function handleRequest(array $middlewares): void
    {
        $requestHandler = new RequestHandler($this->container, $middlewares);

        $this->response = $requestHandler->handle($this->request);
    }
617252
function(arr, req, res, indx, cb) {
    if (arr.length === indx) {
      cb();
    } else {
      arr[indx](req, res, function() {
        middleware(arr, req, res, ++indx, cb);
      });
    }
  }
1007736
public function middleware($request, &$response)
    {
        $that = $this;
        if ($middleware = current($this->middleware)) {
            next($this->middleware);
            $middleware->next($request, $response, function ($request, $response) use ($that) {
                $that->middleware($request, $response);
            });
        }
    }