public function middleware($middlewares)
    {
        $middlewares = (array) $middlewares;

        $this->middlewares = [];

        foreach ($middlewares as $middleware) {
            if (is_callable($middleware)) {
                $this->middlewares[] = $middleware;
            } elseif (class_exists($middleware, true)) {
                $this->middlewares[] = [new $middleware, 'process'];
            } else {
                $this->middlewares[] = $middleware;
            }
        }

        return $this;
    }
public function middleware($middlewares)
    {
        $middlewares = (array) $middlewares;

        $this->middlewares = [];

        foreach ($middlewares as $middleware) {
            if (is_callable($middleware)) {
                $this->middlewares[] = $middleware;
            } elseif (class_exists($middleware, true)) {
                $this->middlewares[] = [new $middleware, 'process'];
            } else {
                $this->middlewares[] = $middleware;
            }
        }

        return $this;
    }
public function middleware ( $ middlewares ) { $ middlewares = ( array ) $ middlewares ; $ this -> middlewares = [ ] ; foreach ( $ middlewares as $ middleware ) { if ( is_callable ( $ middleware ) ) { $ this -> middlewares [ ] = $ middleware ; } elseif ( class_exists ( $ middleware , true ) ) { $ this -> middlewares [ ] = [ new $ middleware , 'process' ] ; } else { $ this -> middlewares [ ] = $ middleware ; } } return $ this ; }
Allows to associate a global middleware on an route

@param array $middlewares
@return Application
Allows to associate a global middleware on an route