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;
    }