eee
This commit is contained in:
@@ -545,4 +545,24 @@ class ConstrictRequest extends Message implements RequestInterface, ServerReques
|
|||||||
}
|
}
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return static
|
||||||
|
*/
|
||||||
|
public static function builder(Request $request): static
|
||||||
|
{
|
||||||
|
$static = (new static())->withUri(new Uri($request));
|
||||||
|
$static->withHeaders($request->header ?? []);
|
||||||
|
$static->withProtocolVersion($request->server['server_protocol']);
|
||||||
|
$static->withCookieParams($request->cookie ?? []);
|
||||||
|
$static->withServerParams($request->server);
|
||||||
|
$static->withQueryParams($request->get ?? []);
|
||||||
|
$static->withBody(new Stream($request->getContent()));
|
||||||
|
$static->withParsedBody($request);
|
||||||
|
$static->withUploadedFiles($request->files ?? []);
|
||||||
|
$static->withMethod($request->getMethod());
|
||||||
|
return $static;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ class Handler implements RequestHandlerInterface
|
|||||||
* @param ReflectionNamedType|null $reflectionType
|
* @param ReflectionNamedType|null $reflectionType
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
public function __construct(public array|Closure $handler, public array $parameter, public ?ReflectionNamedType $reflectionType)
|
public function __construct(public array|Closure $handler, public array $parameter, public ?ReflectionNamedType $reflectionType)
|
||||||
{
|
{
|
||||||
@@ -77,7 +76,6 @@ class Handler implements RequestHandlerInterface
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
public function setRequestMethod(string $method): void
|
public function setRequestMethod(string $method): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use Psr\Container\ContainerExceptionInterface;
|
|||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
use ReflectionMethod;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Traversable;
|
use Traversable;
|
||||||
use Kiri\Router\Base\Middleware;
|
use Kiri\Router\Base\Middleware;
|
||||||
@@ -78,13 +79,15 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$found = di(NotFoundController::class);
|
$found = di(NotFoundController::class);
|
||||||
|
|
||||||
$reflection = new \ReflectionMethod($found, 'fail');
|
$reflection = new ReflectionMethod($found, 'fail');
|
||||||
|
|
||||||
$this->found = new Handler([$found, 'fail'], [], $reflection->getReturnType());
|
$this->found = new Handler([$found, 'fail'], [], $reflection->getReturnType());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user