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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user