Skip to content

Commit

Permalink
feat: update middleware to run on all http methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Oct 2, 2024
1 parent 0e254a5 commit 54d3b5d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,14 @@ public static function use($middleware)
$middleware = static::$namedMiddleware[$middleware];
}

static::$middleware['GET'][] = [
'pattern' => '/.*',
'handler' => $middleware,
];
$methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'];

for ($i=0; $i < count($methods); $i++) {
static::$middleware[$methods[$i]][] = [
'pattern' => '/.*',
'handler' => $middleware,
];
}
}

/**
Expand Down Expand Up @@ -664,7 +668,7 @@ public static function getRoute(): array
*
* @return array
*/
private static function findRoute(
public static function findRoute(
?array $routes = null,
?string $uri = null,
$returnFirst = true
Expand Down

0 comments on commit 54d3b5d

Please sign in to comment.