This commit is contained in:
2023-10-17 20:39:08 +08:00
parent 0007cfeca6
commit 8fed901c0e
2 changed files with 10 additions and 4 deletions
+9 -3
View File
@@ -47,6 +47,12 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
private array $methods = [];
/**
* @var array<string, HttpRequestHandler>
*/
protected array $httpHandler = [];
/**
* @var Handler
*/
@@ -80,9 +86,9 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
* @param HttpRequestHandler $handler
* @return void
*/
public function setMethod(string $method, HttpRequestHandler $handler): void
public function setHttpHandler(string $method, HttpRequestHandler $handler): void
{
$this->methods[$method] = $handler;
$this->httpHandler[$method] = $handler;
}
@@ -237,7 +243,7 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
*/
public function query(string $path, string $method): HttpRequestHandler
{
return $this->methods[$method . '_' . $path] ?? new HttpRequestHandler([], $this->found);
return $this->httpHandler[$method . '_' . $path] ?? new HttpRequestHandler([], $this->found);
}