protected function push(callable $newTopMiddleware)
    {
        $oldStack = $this->middlewareStack;

        if ($oldStack === null) {
            $this->middlewareStack = $newTopMiddleware;

            return $this;
        }

        $this->middlewareStack = function ($request, $response, callable $next) use ($oldStack, $newTopMiddleware) {
            return $newTopMiddleware($request, $response, function ($req, $res) use ($next, $oldStack) {
                return $oldStack($req, $res, $next);
            });
        };

        return $this;
    }