This commit is contained in:
as2252258@163.com
2021-09-12 03:46:24 +08:00
parent 989158bc3d
commit b91199671a
8 changed files with 1151 additions and 1090 deletions
+4 -5
View File
@@ -69,10 +69,9 @@ class Node
}
/**
* @throws NotFindClassException
* @throws ReflectionException
*/
/**
* @param \Http\Route\Router $router
*/
public function __construct(public Router $router)
{
$eventDispatcher = di(EventProvider::class);
@@ -197,7 +196,7 @@ class Node
* @param RequestInterface $request
* @return bool
*/
#[Pure] public function methodAllow(RequestInterface $request): bool
public function methodAllow(RequestInterface $request): bool
{
if (!in_array($request->getMethod(), $this->method)) {
return true;
File diff suppressed because it is too large Load Diff
+238 -191
View File
@@ -3,7 +3,7 @@
namespace Protocol\Message;
use JetBrains\PhpStorm\Pure;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
@@ -13,236 +13,283 @@ use Psr\Http\Message\StreamInterface;
trait Message
{
/**
* @var string
*/
protected string $version;
/**
* @var string
*/
protected string $version;
/**
* @var StreamInterface
*/
protected StreamInterface $stream;
/**
* @var StreamInterface
*/
protected StreamInterface $stream;
/**
* @var array
*/
protected array $headers = [];
/**
* @var array
*/
protected array $headers = [];
/**
* @var array|null
*/
protected ?array $cookieParams = [];
/**
* @var array|null
*/
protected ?array $cookieParams = [];
/**
* @return string
*/
public function getProtocolVersion(): string
{
return $this->version;
}
/**
* @return string
*/
public function getProtocolVersion(): string
{
return $this->version;
}
/**
* @param $version
* @return static
*/
public function withProtocolVersion($version): static
{
$this->version = $version;
return $this;
}
/**
* @param $version
* @return static
*/
public function withProtocolVersion($version): static
{
$this->version = $version;
return $this;
}
/**
* @return array
*/
public function getHeaders(): array
{
return $this->headers;
}
/**
* @return array
*/
public function getHeaders(): array
{
return $this->headers;
}
/**
* @param $name
* @return bool
*/
public function hasHeader($name): bool
{
return array_key_exists($name, $this->headers);
}
/**
* @param $name
* @return bool
*/
public function hasHeader($name): bool
{
return array_key_exists($name, $this->headers);
}
/**
* @param $name
* @return string|array|null
*/
#[Pure] public function getHeader($name): string|null|array
{
if (!$this->hasHeader($name)) {
return null;
}
return $this->headers[$name];
}
/**
* @param $name
* @return string|array|null
*/
#[Pure] public function getHeader($name): string|null|array
{
if (!$this->hasHeader($name)) {
return null;
}
return $this->headers[$name];
}
/**
* @param \Swoole\Http\Request $request
* @return static
*/
public function parseRequestHeaders(\Swoole\Http\Request $request): static
{
$index = strpos($request->getData(), "\r\n\r\n");
$headers = explode("\r\n", substr($request->getData(), 0, $index));
array_shift($headers);
foreach ($headers as $header) {
[$key, $value] = explode(': ', $header);
$this->addRequestHeader($key, $value);
}
return $this;
}
/**
* @return array
*/
public function parse_curl_header(): array
{
$_headers = [];
foreach ($this->headers as $key => $val) {
$_headers[] = $key . ': ' . implode(';', $val);
}
return $_headers;
}
/**
* @param $key
* @param $value
*/
private function addRequestHeader($key, $value)
{
$this->headers[$key] = [$value];
}
/**
* @throws \Exception
*/
public function withData(string $headerString): static
{
[$headers, $body] = explode("\r\n\r\n", $headerString);
$this->stream = new Stream($body);
return $this->slip_headers($headers);
}
/**
* @param $name
* @return string|null
*/
#[Pure] public function getHeaderLine($name): string|null
{
if ($this->hasHeader($name)) {
return implode(';', $this->headers[$name]);
}
return null;
}
/**
* @param $headers
* @return $this
* @throws \Exception
*/
private function slip_headers($headers): static
{
$headers = explode("\r\n", $headers);
$this->resolve_status(array_shift($headers));
foreach ($headers as $header) {
[$key, $value] = explode(': ', $header);
$this->withHeader($key, $value);
}
return $this;
}
/**
* @return string|null
*/
#[Pure] public function getContentType(): ?string
{
return $this->getHeaderLine('Content-Type');
}
/**
* @param string $protocol
*/
private function resolve_status(string $protocol)
{
if ($this instanceof ResponseInterface) {
[$sch, $status, $message] = explode(' ', $protocol);
[$sch, $protocolVersion] = explode('/', $sch);
$this->withProtocolVersion($protocolVersion)
->withStatus(intval($status));
}
}
/**
* @param $name
* @param $value
* @return static
*/
public function withHeader($name, $value): static
{
if (!is_array($value)) {
$value = [$value];
}
$this->headers[$name] = $value;
return $this;
}
/**
* @param $key
* @param $value
*/
private function addRequestHeader($key, $value)
{
$this->headers[$key] = [$value];
}
/**
* @param $name
* @param $value
* @return static
* @throws
*/
public function withAddedHeader($name, $value): static
{
if (!array_key_exists($name, $this->headers)) {
throw new \Exception('Headers `' . $name . '` not exists.');
}
$this->headers[$name][] = $value;
return $this;
}
/**
* @param $name
* @return string|null
*/
#[Pure] public function getHeaderLine($name): string|null
{
if ($this->hasHeader($name)) {
return implode(';', $this->headers[$name]);
}
return null;
}
/**
* @param $name
* @return static
*/
public function withoutHeader($name): static
{
unset($this->headers[$name]);
return $this;
}
/**
* @return string|null
*/
#[Pure] public function getContentType(): ?string
{
return $this->getHeaderLine('Content-Type');
}
/**
* @return null|array
*/
public function getCookieParams(): ?array
{
return $this->cookieParams;
}
/**
* @param $name
* @param $value
* @return static
*/
public function withHeader($name, $value): static
{
if (!is_array($value)) {
$value = [$value];
}
$this->headers[$name] = $value;
return $this;
}
/**
* @param array|null $cookies
* @return static
*/
public function withCookieParams(?array $cookies): static
{
$this->cookieParams = $cookies;
return $this;
}
/**
* @return StreamInterface
*/
public function getBody(): StreamInterface
{
return $this->stream;
}
/**
* @param $name
* @param $value
* @return static
* @throws
*/
public function withAddedHeader($name, $value): static
{
if (!array_key_exists($name, $this->headers)) {
throw new \Exception('Headers `' . $name . '` not exists.');
}
$this->headers[$name][] = $value;
return $this;
}
/**
* @param StreamInterface $body
* @return static
*/
public function withBody(StreamInterface $body): static
{
$this->stream = $body;
return $this;
}
/**
* @param $name
* @return static
*/
public function withoutHeader($name): static
{
unset($this->headers[$name]);
return $this;
}
/**
* @return string|null
*/
#[Pure] public function getAccessControlAllowOrigin(): ?string
{
return $this->getHeaderLine('Access-Control-Allow-Origin');
}
/**
* @return null|array
*/
public function getCookieParams(): ?array
{
return $this->cookieParams;
}
/**
* @return string|null
*/
#[Pure] public function getAccessControlAllowHeaders(): ?string
{
return $this->getHeaderLine('Access-Control-Allow-Headers');
}
/**
* @param array|null $cookies
* @return static
*/
public function withCookieParams(?array $cookies): static
{
$this->cookieParams = $cookies;
return $this;
}
/**
* @return StreamInterface
*/
public function getBody(): StreamInterface
{
return $this->stream;
}
/**
* @return string|null
*/
#[Pure] public function getAccessControlRequestMethod(): ?string
{
return $this->getHeaderLine('Access-Control-Request-Method');
}
/**
* @param StreamInterface $body
* @return static
*/
public function withBody(StreamInterface $body): static
{
$this->stream = $body;
return $this;
}
/**
* @return string|null
*/
#[Pure] public function getAccessControlAllowOrigin(): ?string
{
return $this->getHeaderLine('Access-Control-Allow-Origin');
}
/**
* @return string|null
*/
#[Pure] public function getAccessControlAllowHeaders(): ?string
{
return $this->getHeaderLine('Access-Control-Allow-Headers');
}
/**
* @return string|null
*/
#[Pure] public function getAccessControlRequestMethod(): ?string
{
return $this->getHeaderLine('Access-Control-Request-Method');
}
protected function setStore($key, callable $callback)
{
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ use Psr\Http\Message\UriInterface;
/**
*
*/
abstract class Request implements RequestInterface
class Request implements RequestInterface
{
use Message;
+159 -157
View File
@@ -14,193 +14,195 @@ class ServerRequest extends Request implements ServerRequestInterface
{
/**
* @var mixed
*/
protected ?array $parsedBody = null;
const PARSE_BODY = 'with.parsed.body.callback';
/**
* @var array|null
*/
protected ?array $serverParams;
/**
* @var mixed
*/
protected ?array $parsedBody = null;
/**
* @var array|null
*/
protected ?array $queryParams;
/**
* @var array|null
*/
protected ?array $uploadedFiles;
/**
* @var array|null
*/
protected ?array $serverParams;
protected \Swoole\Http\Request $serverTarget;
/**
* @var array|null
*/
protected ?array $queryParams;
/**
* @var array|null
*/
protected ?array $uploadedFiles;
/**
* @param array $server
* @return static
*/
public function withServerParams(array $server): static
{
$this->serverParams = $server;
return $this;
}
/**
* @param \Swoole\Http\Request $server
* @return static
*/
public function withServerTarget(\Swoole\Http\Request $server): static
{
$this->serverTarget = $server;
return $this;
}
protected \Swoole\Http\Request $serverTarget;
/**
* @param \Swoole\Http\Request $request
* @return static|ServerRequestInterface
*/
public static function createServerRequest(\Swoole\Http\Request $request): static|ServerRequestInterface
{
return (new static())->parseRequestHeaders($request)
->withServerParams($request->server)
->withServerTarget($request)
->withCookieParams($request->cookie)
->withUri(Uri::parseUri($request))
->withBody(new Stream($request->getContent()))
->withQueryParams($request->get ?? [])
->withUploadedFiles($request->files ?? [])
->withMethod($request->getMethod())
->withParsedBody(function (StreamInterface $stream, ?array $posts) {
try {
$content = Parse::data($stream->getContents());
if (!empty($content)) {
return $content;
}
return $posts;
} catch (\Throwable $throwable) {
return $posts;
}
});
}
/**
* @param array $server
* @return static
*/
public function withServerParams(array $server): static
{
$this->serverParams = $server;
return $this;
}
/**
* @param \Swoole\Http\Request $server
* @return static
*/
public function withServerTarget(\Swoole\Http\Request $server): static
{
$this->serverTarget = $server;
return $this;
}
/**
* @return null|array
*/
public function getServerParams(): ?array
{
return $this->serverParams;
}
/**
* @param \Swoole\Http\Request $request
* @return static|ServerRequestInterface
* @throws \Exception
*/
public static function createServerRequest(\Swoole\Http\Request $request): static|ServerRequestInterface
{
$serverRequest = new ServerRequest();
$serverRequest->withData($request->getData());
$serverRequest->withServerParams($request->server);
$serverRequest->withServerTarget($request);
$serverRequest->withCookieParams($request->cookie);
$serverRequest->withUri(Uri::parseUri($request));
$serverRequest->withQueryParams($request->get ?? []);
$serverRequest->withUploadedFiles($request->files ?? []);
$serverRequest->withMethod($request->getMethod());
$serverRequest->withParsedBody($request->post);
return $serverRequest;
}
/**
* @return array|null
*/
public function getQueryParams(): ?array
{
return $this->queryParams;
}
/**
* @return null|array
*/
public function getServerParams(): ?array
{
return $this->serverParams;
}
/**
* @param array $query
* @return ServerRequestInterface
*/
public function withQueryParams(array $query): ServerRequestInterface
{
$this->queryParams = $query;
return $this;
}
/**
* @return array|null
*/
public function getQueryParams(): ?array
{
return $this->queryParams;
}
/**
* @return array|null
*/
public function getUploadedFiles(): ?array
{
return $this->uploadedFiles;
}
/**
* @param array $query
* @return ServerRequestInterface
*/
public function withQueryParams(array $query): ServerRequestInterface
{
$this->queryParams = $query;
return $this;
}
/**
* @param array $uploadedFiles
* @return ServerRequestInterface
*/
public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
{
$this->uploadedFiles = $uploadedFiles;
return $this;
}
/**
* @return array|null
*/
public function getUploadedFiles(): ?array
{
return $this->uploadedFiles;
}
/**
* @return array|object|null
*/
public function getParsedBody(): object|array|null
{
if (empty($this->parsedBody)) {
$callback = Context::getContext('with.parsed.body.callback');
$this->parsedBody = $callback($this->getBody(), $this->serverTarget->post);
}
return $this->parsedBody;
}
/**
* @param array $uploadedFiles
* @return ServerRequestInterface
*/
public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
{
$this->uploadedFiles = $uploadedFiles;
return $this;
}
/**
* @param array|object|null $data
* @return ServerRequestInterface
*/
public function withParsedBody($data): ServerRequestInterface
{
Context::setContext('with.parsed.body.callback', $data);
return $this;
}
/**
* @return array|object|null
*/
public function getParsedBody(): object|array|null
{
if (empty($this->parsedBody)) {
$callback = Context::getContext(self::PARSE_BODY);
$this->parsedBody = $callback($this->getBody(), $this->serverTarget->post);
}
return $this->parsedBody;
}
/**
* @return array
*/
public function getAttributes(): array
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param array|object|null $data
* @return ServerRequestInterface
*/
public function withParsedBody($data): ServerRequestInterface
{
$functions = function (StreamInterface $stream) use ($data) {
$content = Parse::data($stream->getContents());
if (!empty($content)) {
return $content;
}
return $data;
};
Context::setContext(self::PARSE_BODY, $functions);
return $this;
}
/**
* @param string $name
* @param null $default
* @return mixed
*/
public function getAttribute($name, $default = null): mixed
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @return array
*/
public function getAttributes(): array
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param string $name
* @param mixed $value
* @return ServerRequestInterface
*/
public function withAttribute($name, $value): ServerRequestInterface
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param string $name
* @param null $default
* @return mixed
*/
public function getAttribute($name, $default = null): mixed
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param string $name
* @return ServerRequestInterface
*/
public function withoutAttribute($name): ServerRequestInterface
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param string $name
* @param mixed $value
* @return ServerRequestInterface
*/
public function withAttribute($name, $value): ServerRequestInterface
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param string $name
* @return ServerRequestInterface
*/
public function withoutAttribute($name): ServerRequestInterface
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
}
+202 -201
View File
@@ -10,246 +10,247 @@ class Uri implements UriInterface
{
protected string $scheme = '';
protected string $host = '';
protected string $path = '';
protected string $fragment = '';
protected int $port = 80;
protected string $scheme = '';
protected string $host = '';
protected string $path = '';
protected string $fragment = '';
protected int $port = 80;
protected string $queryString = '';
protected string $queryString = '';
/**
* @return string
*/
public function getScheme(): string
{
return $this->scheme;
}
/**
* @return string
*/
public function getScheme(): string
{
return $this->scheme;
}
/**
* @return string
*/
public function getAuthority(): string
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @return string
*/
public function getAuthority(): string
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @return string
*/
public function getUserInfo(): string
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @return string
*/
public function getUserInfo(): string
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @return string
*/
public function getHost(): string
{
return $this->host;
}
/**
* @return int|null
*/
public function getPort(): ?int
{
return $this->port;
}
/**
* @return string
*/
public function getHost(): string
{
return $this->host;
}
/**
* @return string
*/
public function getPath(): string
{
return $this->path;
}
/**
* @return int|null
*/
public function getPort(): ?int
{
return $this->port;
}
/**
* @return string
*/
public function getQuery(): string
{
return $this->queryString;
}
/**
* @return string
*/
public function getPath(): string
{
return $this->path;
}
/**
* @return string
*/
public function getFragment(): string
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @return string
*/
public function getQuery(): string
{
return $this->queryString;
}
/**
* @param string $scheme
* @return $this|Uri
*/
public function withScheme($scheme): UriInterface
{
$this->scheme = $scheme;
return $this;
}
/**
* @return string
*/
public function getFragment(): string
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param string $user
* @param null $password
* @return Uri
*/
public function withUserInfo($user, $password = null): UriInterface
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param string $scheme
* @return $this|Uri
*/
public function withScheme($scheme): UriInterface
{
$this->scheme = $scheme;
return $this;
}
/**
* @param string $host
* @return $this|Uri
*/
public function withHost($host): UriInterface
{
$this->host = $host;
return $this;
}
/**
* @param string $user
* @param null $password
* @return Uri
*/
public function withUserInfo($user, $password = null): UriInterface
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param int|null $port
* @return $this|Uri
*/
public function withPort($port): UriInterface
{
$this->port = $port;
return $this;
}
/**
* @param string $host
* @return $this|Uri
*/
public function withHost($host): UriInterface
{
$this->host = $host;
return $this;
}
/**
* @param string $path
* @return $this|Uri
*/
public function withPath($path): UriInterface
{
$this->path = $path;
return $this;
}
/**
* @param int|null $port
* @return $this|Uri
*/
public function withPort($port): UriInterface
{
$this->port = $port;
return $this;
}
/**
* @param string $query
* @return $this|Uri
*/
public function withQuery($query): UriInterface
{
$this->queryString = $query;
return $this;
}
/**
* @param string $path
* @return $this|Uri
*/
public function withPath($path): UriInterface
{
$this->path = $path;
return $this;
}
/**
* @param string $fragment
* @return Uri
*/
public function withFragment($fragment): UriInterface
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @param string $query
* @return $this|Uri
*/
public function withQuery($query): UriInterface
{
$this->queryString = $query;
return $this;
}
/**
* @return string
*/
public function __toString(): string
{
$domain = sprintf('%s://%s', $this->scheme, $this->host);
if (!in_array($this->port, [80, 443])) {
$domain .= ':' . $this->port;
}
if (empty($this->query) && empty($this->fragment)) {
return $domain . $this->path;
}
return sprintf('%s?%s#%s', $domain . $this->path,
$this->queryString, $this->fragment);
}
/**
* @param string $fragment
* @return Uri
*/
public function withFragment($fragment): UriInterface
{
throw new \BadMethodCallException('Not Accomplish Method.');
}
/**
* @return int
*/
public function getDefaultPort(): int
{
return $this->scheme == 'https' ? 443 : 80;
}
/**
* @return string
*/
public function __toString(): string
{
$domain = sprintf('%s://%s', $this->scheme, $this->host);
if (!in_array($this->port, [80, 443])) {
$domain .= ':' . $this->port;
}
if (empty($this->query) && empty($this->fragment)) {
return $domain . $this->path;
}
return sprintf('%s?%s#%s', $domain . $this->path,
$this->queryString, $this->fragment);
}
/**
* @param Request $request
* @return UriInterface
*/
public static function parseUri(Request $request): UriInterface
{
$server = $request->server;
$header = $request->header;
$uri = new static();
$uri = $uri->withScheme(!empty($server['https']) && $server['https'] !== 'off' ? 'https' : 'http');
if (isset($request->header['x-forwarded-proto'])) {
$uri->withScheme($request->header['x-forwarded-proto'])->withPort(443);
}
/**
* @return int
*/
public function getDefaultPort(): int
{
return $this->scheme == 'https' ? 443 : 80;
}
$hasPort = false;
if (isset($server['http_host'])) {
$hostHeaderParts = explode(':', $server['http_host']);
$uri = $uri->withHost($hostHeaderParts[0]);
if (isset($hostHeaderParts[1])) {
$hasPort = true;
$uri = $uri->withPort($hostHeaderParts[1]);
}
} elseif (isset($server['server_name'])) {
$uri = $uri->withHost($server['server_name']);
} elseif (isset($server['server_addr'])) {
$uri = $uri->withHost($server['server_addr']);
} elseif (isset($header['host'])) {
$hasPort = true;
if (strpos($header['host'], ':')) {
[$host, $port] = explode(':', $header['host'], 2);
if ($port != $uri->getDefaultPort()) {
$uri = $uri->withPort($port);
}
} else {
$host = $header['host'];
}
$uri = $uri->withHost($host);
}
/**
* @param Request $request
* @return UriInterface
*/
public static function parseUri(Request $request): UriInterface
{
$server = $request->server;
$header = $request->header;
$uri = new static();
$uri = $uri->withScheme(!empty($server['https']) && $server['https'] !== 'off' ? 'https' : 'http');
if (isset($request->header['x-forwarded-proto'])) {
$uri->withScheme($request->header['x-forwarded-proto'])->withPort(443);
}
if (!$hasPort && isset($server['server_port'])) {
$uri = $uri->withPort($server['server_port']);
}
$hasPort = false;
if (isset($server['http_host'])) {
$hostHeaderParts = explode(':', $server['http_host']);
$uri = $uri->withHost($hostHeaderParts[0]);
if (isset($hostHeaderParts[1])) {
$hasPort = true;
$uri = $uri->withPort($hostHeaderParts[1]);
}
} elseif (isset($server['server_name'])) {
$uri = $uri->withHost($server['server_name']);
} elseif (isset($server['server_addr'])) {
$uri = $uri->withHost($server['server_addr']);
} elseif (isset($header['host'])) {
$hasPort = true;
if (strpos($header['host'], ':')) {
[$host, $port] = explode(':', $header['host'], 2);
if ($port != $uri->getDefaultPort()) {
$uri = $uri->withPort($port);
}
} else {
$host = $header['host'];
}
$hasQuery = false;
if (isset($server['request_uri'])) {
$requestUriParts = explode('?', $server['request_uri']);
$uri = $uri->withPath($requestUriParts[0]);
if (isset($requestUriParts[1])) {
$hasQuery = true;
$uri = $uri->withQuery($requestUriParts[1]);
}
}
$uri = $uri->withHost($host);
}
if (!$hasQuery && isset($server['query_string'])) {
$uri = $uri->withQuery($server['query_string']);
}
if (!$hasPort && isset($server['server_port'])) {
$uri = $uri->withPort($server['server_port']);
}
return $uri;
}
$hasQuery = false;
if (isset($server['request_uri'])) {
$requestUriParts = explode('?', $server['request_uri']);
$uri = $uri->withPath($requestUriParts[0]);
if (isset($requestUriParts[1])) {
$hasQuery = true;
$uri = $uri->withQuery($requestUriParts[1]);
}
}
if (!$hasQuery && isset($server['query_string'])) {
$uri = $uri->withQuery($server['query_string']);
}
return $uri;
}
}
+5 -4
View File
@@ -49,10 +49,11 @@ class Request implements RequestInterface
}
/**
* @param \Swoole\Http\Request $request
* @return Request
*/
/**
* @param \Swoole\Http\Request $request
* @return Request
* @throws \Exception
*/
public static function create(\Swoole\Http\Request $request): Request
{
$serverRequest = ServerRequest::createServerRequest($request);
+1 -1
View File
@@ -42,7 +42,7 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect
public function onRequest(Request $request, Response $response): void
{
try {
$node = $this->router->Branch_search($Psr7Request = ScRequest::create($request));
$node = $this->router->radix_tree($Psr7Request = ScRequest::create($request));
if (!($node instanceof Node)) {
throw new RequestException(Constant::STATUS_404_MESSAGE, 404);
}