This commit is contained in:
xl
2023-11-22 10:19:33 +08:00
parent 3bf66cefe2
commit e0e5455576
2 changed files with 33 additions and 2 deletions
+7 -2
View File
@@ -7,6 +7,7 @@ use Closure;
use Kiri\Router\Format\ArrayFormat;
use Kiri\Router\Format\IFormat;
use Kiri\Router\Format\MixedFormat;
use Kiri\Router\Format\NoBody;
use Kiri\Router\Format\OtherFormat;
use Kiri\Router\Format\ResponseFormat;
use Kiri\Router\Format\VoidFormat;
@@ -36,13 +37,14 @@ class Handler implements RequestHandlerInterface
/**
* @param array|Closure $handler
* @param string $method
* @param array $parameter
* @param ReflectionNamedType|null $reflectionType
* @throws ReflectionException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function __construct(public array|Closure $handler, public array $parameter, public ?ReflectionNamedType $reflectionType)
public function __construct(public array|Closure $handler, string $method, public array $parameter, public ?ReflectionNamedType $reflectionType)
{
$this->container = \Kiri::getDi();
if ($this->reflectionType != null) {
@@ -50,6 +52,9 @@ class Handler implements RequestHandlerInterface
} else {
$this->format = $this->container->get(MixedFormat::class);
}
if ($method === 'HEAD') {
$this->format = $this->container->get(NoBody::class);
}
}