mirror of
https://github.com/dannyvankooten/AltoRouter.git
synced 2025-08-08 09:26:33 +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:
@@ -189,18 +189,9 @@ class AltoRouter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->routes as $handler) {
|
foreach($this->routes as $handler) {
|
||||||
list($method, $_route, $target, $name) = $handler;
|
list($methods, $_route, $target, $name) = $handler;
|
||||||
|
|
||||||
$methods = explode('|', $method);
|
$method_match = (stripos($methods, $requestMethod) !== false);
|
||||||
$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 did not match, continue to next route.
|
// Method did not match, continue to next route.
|
||||||
if(!$method_match) continue;
|
if(!$method_match) continue;
|
||||||
|
Reference in New Issue
Block a user