private function route(ServerRequestInterface $request)
    {
        $route = $request->getAttribute('route', false);
        if (! $route instanceof Route) {
            throw new BadHttpStackConfigurationException(
                "Dispatcher works with router middleware in order to process incoming requests. " .
                "Please check that the HTTP stack has the router middleware placed before the dispatcher. ".
                "Missing route in the request."
            );
        }
        return $route;
    }