1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-08-06 08:27:39 +02:00

Merge pull request #130 from dannyvankooten/strpos-request-method

Use `stripos` to compare request method (instead of `explode` + `in_array`) for improved performance.
This commit is contained in:
Danny van Kooten
2016-06-21 22:37:56 +02:00
committed by GitHub

View File

@@ -189,18 +189,9 @@ class AltoRouter {
}
foreach($this->routes as $handler) {
list($method, $_route, $target, $name) = $handler;
list($methods, $_route, $target, $name) = $handler;
$methods = explode('|', $method);
$method_match = false;
// Check if request method matches. If not, abandon early. (CHEAP)
foreach($methods as $method) {
if (strcasecmp($requestMethod, $method) === 0) {
$method_match = true;
break;
}
}
$method_match = (stripos($methods, $requestMethod) !== false);
// Method did not match, continue to next route.
if(!$method_match) continue;