Esempio n. 1
0
 /**
  * Gets the route for he current request
  *
  * @param \PitchBlade\Network\Http\RequestData $request The request data
  *
  * @return \PitchBlade\Router\AccessPoint                The matching route
  * @throws \PitchBlade\Router\UnsupportedMethodException When the request contains an unspported method
  * @throws \PitchBlade\Router\NotFoundException          When no route matches
  */
 public function getRoute(RequestData $request)
 {
     if (!array_key_exists($request->getMethod(), $this->routes)) {
         throw new UnsupportedMethodException('The `' . $request->getMethod() . '` method is currently not implemented.');
     }
     foreach ($this->routes[$request->getMethod()] as $route) {
         if ($route->matchesRequest($request)) {
             return $route;
         }
     }
     throw new NotFoundException('No route matches the request.');
 }