Register the Debugbar Middleware

@param  string $middleware
965296
protected function registerMiddleware($middleware)
    {
        /** @var Kernel $kernel */
        $kernel = $this->getContainer()->get(KernelInterface::class);
        $kernel->prependMiddleware($middleware);
    }
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>");
        }
    }
563020
protected function registerMiddlewares()
    {
        // Init middlewares
        $middlewares = (array) $this->config->get('middlewares', []);

        foreach ($middlewares as $k => $middleware) {
            $this->addMiddleware($middleware, is_numeric($k) ? $k : PriorityQueue::NORMAL);
        }

        // Remove closures
        $this->config->set('middlewares', null);
    }
1273730
private function loadMiddlewares($app, $container)
    {
        # Tracy debugbar
        $debugbar_enabled = filter_var(app_env('DEBUG_BAR_ON', false), FILTER_VALIDATE_BOOLEAN);
        if (is_dev() && $debugbar_enabled && PHP_SAPI !== "cli")
        {
            $app->add(new TracyMiddleware($app));
        }

        # Determine Route Before Application middleware
        $app->add(new AppMiddleware($container));

        # Global Error middleware
        $app->add(new GlobalErrorsMiddleware($container));

        # Old Input middleware
        $app->add(new OldInputMiddleware($container));

        # Global Csrf middleware
        $app->add(new GlobalCsrfMiddleware($container));
        $app->add($container->get('csrf'));

        # Shared Server middleware
        $app->add(new SharedServerMiddleware($container));

        # Application Mode middleware
        $app->add(new AppModeMiddleware($container));

        # Remove Trailing Slash middleware
        $app->add(new RemoveTrailingSlashMiddleware($container));
    }
16779
public function add($path, $middleware = null)
    {
        if (!isset($middleware)) {
            $middleware = $path;
            $path = null;
        }

        if (!empty($path) && !ctype_digit($path) && $path[0] !== '/') {
            trigger_error("Middleware path '$path' doesn't start with a '/'", E_USER_NOTICE);
        }
        
        if (!is_callable($middleware)) {
            throw new \InvalidArgumentException("Middleware should be callable");
        }

        if (!empty($path)) {
            $middleware = $this->wrapMiddleware($path, $middleware);
        }
        
        $this->middlewares[] = $middleware;
        
        return $this;
    }
97631
private function registerMiddlewareMakeCommand()
    {
        $this->app->bindShared('command.make.package.middleware', function ($app)
        {
            return new MiddlewareMakeCommand($app['files'], $app['packages']);
        });

        $this->commands('command.make.package.middleware');
    }
555690
protected function registerMiddleware()
    {
        $this->app->singleton(Request::class, function ($app) {
            $middleware = new Middleware\Request(
                $app,
                $app[ExceptionHandler::class],
                $app[Router::class],
                $app[RequestValidator::class],
                $app['events']
            );

            $middleware->setMiddlewares($this->config('middleware', false));

            return $middleware;
        });

        $this->app->singleton(AuthMiddleware::class, function ($app) {
            return new Middleware\Auth($app[Router::class], $app[Auth::class]);
        });

        $this->app->singleton(RateLimit::class, function ($app) {
            return new Middleware\RateLimit($app[Router::class], $app[Handler::class]);
        });

        $this->app->singleton(PrepareController::class, function ($app) {
            return new Middleware\PrepareController($app[Router::class]);
        });
    }
707866
private function handleRequest(array $middlewares): void
    {
        $requestHandler = new RequestHandler($this->container, $middlewares);

        $this->response = $requestHandler->handle($this->request);
    }
658967
public function generate($middleware)
    {
        $generator = new Generator(
            $this->setting->getMiddlewareDirectory(),
            $middleware
        );

        if ($generator->fileExists()) {
            echo "\033[0;31mThe middleware already exists.\033[00m\n";

            exit(1);
        }

        $generator->write('middleware', [
            'baseNamespace' => $this->namespaces['middleware']
        ]);

        echo "\033[0;32mThe middleware has been well created.\033[00m\n";

        exit(0);
    }
1315684
public function addMiddleware($middleware, array $properties = array())
    {
        if($this->route)
        {
            $this->route->addMiddleware($middleware, $properties);
        }
        else
        {
            $this->middlewares[] = array($middleware, $properties);
        }

        return $this;
    }
474129
public function append(MiddlewareInterface $middleware): MiddlewarePipe
    {
        $stack = new MiddlewarePipe();

        /** @noinspection PhpParamsInspection */
        return $stack
            ->append($this)
            ->append($middleware);
    }
956293
public function runRouteMiddleware($middleware, $type)
    {
        $middlewarePath = $this->baseFolder . '/' . $this->paths['middlewares'];
        $middlewareNs = $this->namespaces['middlewares'];
        if ($type == 'before') {
            if (! is_null($middleware['group'])) {
                $this->routerCommand()->beforeAfter(
                    $middleware['group'][$type], $middlewarePath, $middlewareNs
                );
            }
            $this->routerCommand()->beforeAfter(
                $middleware[$type], $middlewarePath, $middlewareNs
            );
        } else {
            $this->routerCommand()->beforeAfter(
                $middleware[$type], $middlewarePath, $middlewareNs
            );
            if (! is_null($middleware['group'])) {
                $this->routerCommand()->beforeAfter(
                    $middleware['group'][$type], $middlewarePath, $middlewareNs
                );
            }
        }
    }
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);
        }
    }
978820
public function pushMiddleware(array $middlewares)
    {
        foreach ($middlewares as $key => $middleware) {
            $this->middlewares[$key] = $middleware;
        }
    }
47574
public function registerDebuggee(array $args = [])
    {
        return $this->send([$this->controllerClient, 'registerDebuggee'], [
            $this->serializer->decodeMessage(
                new Debuggee(),
                $this->pluck('debuggee', $args)
            ),
            $args
        ]);
    }
451304
private function decorate($middleware): MiddlewareInterface
    {
        if ($middleware instanceof MiddlewareInterface) {
            return $middleware;
        } elseif ($middleware instanceof RequestHandlerInterface) {
            return new RequestHandlerMiddleware($middleware);
        } elseif ($middleware instanceof ResponseInterface) {
            return new FixedResponseMiddleware($middleware);
        } elseif (is_callable($middleware)) {
            return new CallableMiddleware($middleware);
        } elseif (is_string($middleware)) {
            return new LazyLoadingMiddleware($middleware, $this->container);
        } else {
            throw new InvalidArgumentException(sprintf(
                'Middleware "%s" is neither a string service name, an autoloadable class name, a PHP callable, or an instance of %s/%s/%s',
                is_object($middleware) ? get_class($middleware) : gettype($middleware),
                MiddlewareInterface::class, ResponseInterface::class, RequestHandlerInterface::class
            ));
        }
    }
979768
public function middleware( $middleware = null )
	{
		if ( is_null( $middleware ) )
			return (array) Arr::get( $this->action, 'middleware', [] );

		if ( is_string( $middleware ) )
			$middleware = [$middleware];

		$this->action['middleware'] = array_merge( (array) Arr::get( $this->action, 'middleware', [] ), $middleware );

		return $this;
	}