public function addMiddleware($middleware, bool $prepend = false)
    {
        if (!is_array($middleware)) {
            $middleware = [$middleware];
        }

        if ($prepend) {
            $this->middleware = array_merge($middleware, $this->middleware);
        } else {
            $this->middleware = array_merge($this->middleware, $middleware);
        }

        $this->middleware = array_unique($this->middleware, SORT_REGULAR);
    }