Register Middleware
        :param middleware: The Middleware Function
437373
def use(self, *middleware: MiddlewareType) -> None:
        
        for m in middleware:
            if is_middleware(m):
                self.middleware.append(m)
15141
def add_middleware(middleware: EFBMiddleware):
    
    global middlewares
    if isinstance(middleware, EFBMiddleware):
        middlewares.append(middleware)
    else:
        raise TypeError("Middleware instance is expected")
451750
protected function registerMiddleware()
    {
        $this->app->bind('tactician.middleware', function() {
            $middleware = $this->config('middleware');
            $resolved   = array_map(function($name) {
                if (is_string($name)) {
                    return $this->app->make($name);
                }
                return $name;
            }, $middleware);

            $resolved[] = $this->app['tactician.handler'];

            return $resolved;
        });
    }
965296
protected function registerMiddleware($middleware)
    {
        /** @var Kernel $kernel */
        $kernel = $this->getContainer()->get(KernelInterface::class);
        $kernel->prependMiddleware($middleware);
    }
882183
function Router() {
  var self = this;
  this._routes = {};

  this.middleware = function(req, res, next) {
    self._dispatch(req, res, next);
  };
}
276547
def register(self, procedure=None, options=None):
        

        def decorator(func):
            if self._started:
                self.session.register(endpoint=func, procedure=procedure, options=options)
            else:

                def registerer():
                    self.session.register(endpoint=func, procedure=procedure, options=options)

                # Wait for the WAMP session to be started
                self._on_running_callbacks.append(registerer)
            return func

        return decorator
446940
function bindMiddlewares() {
		var modelName,
			_this = this;

		for(modelName in Rhapsody.models) {

			(function(model) {

				model.options.middlewares.forEach(function(middleware) {
					if(typeof middleware !== 'function') {
						middleware = require(path.join(Rhapsody.root, '/app/middlewares/' + middleware));
					}

					modelName = '/' + modelName;

					_this.router.post(modelName, middleware);
					_this.router.post(modelName + '/:id/:relationship', middleware);
					_this.router.get(modelName + '/:id?', middleware);
					_this.router.get(modelName + '/:id/:relationship', middleware);
					_this.router.put(modelName + '/:id', middleware);
					_this.router.patch(modelName + '/:id', middleware);
					_this.router.delete(modelName + '/:id', middleware);
				});

			}(Rhapsody.models[modelName]));
		}
	}
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')
        }
    }
438556
public function initialize()
    {
        if ($this->hasMiddlewares()) {
            foreach ($this->middlewares as $middleware) {
                $middleware->initialize();
            }

            Strata::app()->log(sprintf("Loaded <info>%d</info> middlewares", count($this->middlewares)), "<info>Middleware</info>");
        }
    }
35568
protected function registerRoute($method, $path, $callback, $middleware = null)
    {
        if ($this->debug) echo __METHOD__ . " : " . json_encode([$method, $path, $callback, $middleware]) . PHP_EOL;
        $path = preg_replace('/\//', '\/', $path);
        $matched = preg_match_all('/\{([^\/]+)\}/', $path, $matches);
        if ($this->debug) echo "Regex Route Variable Components Matched: " . json_encode($matches) . PHP_EOL;
        if ($matched) {
            $regex = preg_replace('/\{([^\/]+)\}/', '([^\/]+)', $path);
        } else {
            $regex = $path;
        }
        $regex = '/^\/' . $regex . '$/';
        $new_route = [
            self::ROUTE_PARAM_METHOD => $method,
            self::ROUTE_PARAM_PATH => $regex,
            self::ROUTE_PARAM_CALLBACK => $callback,
            self::ROUTE_PARAM_MIDDLEWARE => $middleware,
        ];
        if ($this->debug) echo "New Regex Route: " . json_encode($new_route) . PHP_EOL;
        array_unshift($this->routes, $new_route);
    }
708519
protected function registerMiddlewares()
    {
        if (!$this->app['config']->get('laratrust.middleware.register')) {
            return;
        }

        $router = $this->app['router'];

        if (method_exists($router, 'middleware')) {
            $registerMethod = 'middleware';
        } elseif (method_exists($router, 'aliasMiddleware')) {
            $registerMethod = 'aliasMiddleware';
        } else {
            return;
        }

        foreach ($this->middlewares as $key => $class) {
            $router->$registerMethod($key, $class);
        }
    }
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);
			});
		}
	}
171904
public function registerMiddleware($middlewareInstance)
    {
        if (isset(class_uses($middlewareInstance)['Nf\Middleware\Pre'])) {
            $key = self::MIDDLEWARE_PRE;
        } else {
            $key = self::MIDDLEWARE_POST;
        }
        // adds the middleware
        $this->registeredMiddlewares[$key][] = $middlewareInstance;
    }
1093665
def register(self, endpoint, procedure=None, options=None):
        
        def proxy_endpoint(*args, **kwargs):
            return self._callbacks_runner.put(partial(endpoint, *args, **kwargs))
        return self._async_session.register(proxy_endpoint, procedure=procedure, options=options)
428263
def make_middleware(self, app):
        

        def application(environ, start_response):
            return ClosingIterator(app(environ, start_response), self.cleanup)

        return application
1016249
protected function addMiddleware($middleware)
    {
        $kernel = $this->app['Illuminate\Contracts\Http\Kernel'];

        if (is_array($middleware)) {
            foreach ($middleware as $ware) {
                $kernel->pushMiddleware($ware);
            }
        } else {
            $kernel->pushMiddleware($middleware);
        }
    }
945773
function use(events, middleware)
{
  // if no middleware supplied assume it's single argument call
  if (!middleware)
  {
    middleware = events;
    events     = null;
  }

  // make it uniform
  events = normalizeEvents(events);

  // store middleware per event
  events.forEach(function(e)
  {
    // bind middleware to the current context
    (this._stack[e] = this._stack[e] || []).push(middleware.bind(this));

    // make mark in history
    this.logger.debug({message: 'Added middleware to the stack', event: e, middleware: middleware});
  }.bind(this));
}