Exemplo n.º 1
0
 /**
  * Find route matched for given request.
  *
  * @param ServerRequestInterface $request
  * @param string                 $basePath
  * @return null|RouteInterface
  */
 protected function findRoute(ServerRequestInterface $request, $basePath)
 {
     foreach ($this->routes as $route) {
         if ($route->match($request, $basePath)) {
             return $route;
         }
     }
     if ($this->defaultRoute->match($request, $basePath)) {
         return $this->defaultRoute;
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * Find route matched for given request.
  *
  * @param ServerRequestInterface $request
  * @return null|RouteInterface
  */
 protected function findRoute(ServerRequestInterface $request)
 {
     foreach ($this->routes as $route) {
         if (!empty($matched = $route->match($request))) {
             if ($matched instanceof RouteInterface) {
                 return $matched;
             }
             throw new RouterException("Matched route must return RouteInterface instance");
         }
     }
     if (!empty($this->defaultRoute) && !empty($matched = $this->defaultRoute->match($request))) {
         return $matched;
     }
     return null;
 }