protected function terminateRouteMiddleware(Request $request, Response $response): void
    {
        // Ensure a route exists
        if (! $this->app->container()->isSingleton(Route::class)) {
            return;
        }

        /* @var Route $route */
        $route = $this->app->container()->getSingleton(Route::class);

        // If the dispatched route has middleware
        if (null !== $route->getMiddleware()) {
            // Terminate each middleware
            $this->terminableMiddleware(
                $request,
                $response,
                $route->getMiddleware()
            );
        }
    }