Made sure not to iterate over StaticRoutes again because the key they map to is a specific child Handler

This commit is contained in:
Phil 2015-01-01 20:17:48 +00:00
parent 3aca197d7a
commit bb052625af
1 changed files with 12 additions and 9 deletions

View File

@ -49,16 +49,19 @@ class Router implements HandlerInterface
$handler = new $this->routes[$path](); $handler = new $this->routes[$path]();
$response = $handler->getResponse($request, $args); $response = $handler->getResponse($request, $args);
} else { } else {
foreach ($this->routes as $route) { foreach ($this->routes as $path => $route) {
/** @var HandlerInterface $route */ // Only take elements that are not $path => $handler mapped.
try { if (is_int($path)) {
$response = $route->getResponse($request, $args); /** @var HandlerInterface $route */
} catch (HttpException $e) { try {
$response = new Response(); $response = $route->getResponse($request, $args);
$response->setStatusCode($e->getCode()); } catch (HttpException $e) {
$response->setBody($e->getMessage()); $response = new Response();
$response->setStatusCode($e->getCode());
$response->setBody($e->getMessage());
}
if ($response) break;
} }
if ($response) break;
} }
} }
if ($response) { if ($response) {