Alternative attempt at support HEAD requests.
This commit is contained in:
parent
0472625a00
commit
3fcedb55ef
1 changed files with 3 additions and 2 deletions
|
@ -113,6 +113,9 @@ class HttpRouter implements IRouter {
|
||||||
if(trim($method) !== $method)
|
if(trim($method) !== $method)
|
||||||
throw new InvalidArgumentException('$method may start or end with whitespace');
|
throw new InvalidArgumentException('$method may start or end with whitespace');
|
||||||
|
|
||||||
|
if($method === 'GET')
|
||||||
|
$this->add('HEAD', $path, $handler);
|
||||||
|
|
||||||
$prepared = self::preparePath($path, false);
|
$prepared = self::preparePath($path, false);
|
||||||
if($prepared === false) {
|
if($prepared === false) {
|
||||||
if(str_ends_with($path, '/'))
|
if(str_ends_with($path, '/'))
|
||||||
|
@ -131,8 +134,6 @@ class HttpRouter implements IRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resolve(string $method, string $path): ResolvedRouteInfo {
|
public function resolve(string $method, string $path): ResolvedRouteInfo {
|
||||||
if($method === 'head')
|
|
||||||
$method = 'get';
|
|
||||||
if(str_ends_with($path, '/'))
|
if(str_ends_with($path, '/'))
|
||||||
$path = substr($path, 0, -1);
|
$path = substr($path, 0, -1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue