Permalink
Browse files

updating to check for routes on a method

  • Loading branch information...
1 parent f211d14 commit 03c49240b3d5591a3ef91e829979cb75499d30d8 @enygma committed Aug 7, 2012
Showing with 14 additions and 12 deletions.
  1. +14 −12 Shield/Shield.php
View
26 Shield/Shield.php
@@ -176,25 +176,27 @@ public function run()
$method = strtolower($requestMethod);
if (isset($this->routes[$method][$uri])) {
- $this->routeMatch($method,$uri,$uri);
+ $this->routeMatch($method, $uri, $uri);
} else {
$found = false;
- // loop through our routes and see if there's a regex match
- foreach ($this->routes[$method] as $route => $handler) {
- if (preg_match('#^'.$route.'$#', $uri, $matches) === 1 && $found == false) {
- $found = true;
- $this->routeMatch($method,$route,$matches);
+ if (isset($this->routes[$method])) {
+ // loop through our routes and see if there's a regex match
+ foreach ($this->routes[$method] as $route => $handler) {
+ if (preg_match('#^'.$route.'$#', $uri, $matches) === 1 && $found == false) {
+ $found = true;
+ $this->routeMatch($method, $route, $matches);
+ }
}
- }
- if ($found == false) {
- // return a 404 header
- header('HTTP/1.0 404 Not Found');
+ if ($found == false) {
+ // return a 404 header
+ header('HTTP/1.0 404 Not Found');
- $this->di->get('Log')->log('NO ROUTE MATCH ['.strtoupper($method).']: '.$uri);
- $this->throwError('No route match for "'.$uri.'"');
+ $this->di->get('Log')->log('NO ROUTE MATCH ['.strtoupper($method).']: '.$uri);
+ $this->throwError('No route match for "'.$uri.'"');
+ }
}
}
}

0 comments on commit 03c4924

Please sign in to comment.