This commit is contained in:
2023-10-17 20:13:29 +08:00
parent 72638acc7c
commit 689c883830
4 changed files with 62 additions and 38 deletions
+14 -3
View File
@@ -66,6 +66,17 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
}
/**
* @param string $method
* @param HttpRequestHandler $handler
* @return void
*/
public function setMethod(string $method, HttpRequestHandler $handler): void
{
$this->methods[$method] = $handler;
}
/**
* @return array
*/
@@ -213,11 +224,11 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
/**
* @param string $path
* @param string $method
* @return Handler
* @return HttpRequestHandler
*/
public function query(string $path, string $method): Handler
public function query(string $path, string $method): HttpRequestHandler
{
return $this->methods[$method . '_' . $path] ?? $this->found;
return $this->methods[$method . '_' . $path] ?? new HttpRequestHandler([], $this->found);
}