public function route(Request $request) : Response
    {
        $method = $request->getMethod();

        /** @var ParsedRoute $route */
        foreach ($this->routeCollection->get($method) as $route) {
            $compiledRoute = $this->compiler->compile($route, $request);

            if ($compiledRoute->isMatch()) {
                $this->matchedRoute = $compiledRoute;

                return $this->dispatcher->dispatch($this->matchedRoute, $request, $this->matchedController);
            }
        }

        // If we've gotten here, we've got a missing route
        throw new HttpException(404);
    }
public function route(Request $request) : Response
    {
        $method = $request->getMethod();

        /** @var ParsedRoute $route */
        foreach ($this->routeCollection->get($method) as $route) {
            $compiledRoute = $this->compiler->compile($route, $request);

            if ($compiledRoute->isMatch()) {
                $this->matchedRoute = $compiledRoute;

                return $this->dispatcher->dispatch($this->matchedRoute, $request, $this->matchedController);
            }
        }

        // If we've gotten here, we've got a missing route
        throw new HttpException(404);
    }
public function route ( Request $ request ) : Response { $ method = $ request -> getMethod ( ) ; /** @var ParsedRoute $route */ foreach ( $ this -> routeCollection -> get ( $ method ) as $ route ) { $ compiledRoute = $ this -> compiler -> compile ( $ route , $ request ) ; if ( $ compiledRoute -> isMatch ( ) ) { $ this -> matchedRoute = $ compiledRoute ; return $ this -> dispatcher -> dispatch ( $ this -> matchedRoute , $ request , $ this -> matchedController ) ; } } // If we've gotten here, we've got a missing route throw new HttpException ( 404 ) ; }
Routes a request

@param Request $request The request to route
@return Response The response from the controller
@throws RouteException Thrown if the controller or method could not be called
@throws HttpException Thrown if there was no matching route
Routes a request