改名
This commit is contained in:
@@ -19,12 +19,29 @@ abstract class Handler implements RequestHandlerInterface
|
||||
private int $offset = 0;
|
||||
|
||||
|
||||
protected CHl $handler;
|
||||
|
||||
protected ?array $middlewares;
|
||||
|
||||
/**
|
||||
* @param CHl $handler
|
||||
* @param array|null $middlewares
|
||||
* @return $this
|
||||
*/
|
||||
public function __construct(protected CHl $handler, protected ?array $middlewares)
|
||||
public function setHandler(CHl $handler): static
|
||||
{
|
||||
$this->handler = $handler;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array|null $middlewares
|
||||
* @return $this
|
||||
*/
|
||||
public function setMiddlewares(?array $middlewares): static
|
||||
{
|
||||
$this->middlewares = $middlewares;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Server\Service;
|
||||
|
||||
|
||||
use Annotation\Inject;
|
||||
use Exception;
|
||||
use Http\Context\Context;
|
||||
use Http\Exception\RequestException;
|
||||
@@ -35,6 +36,10 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect
|
||||
{
|
||||
|
||||
|
||||
#[Inject(Dispatcher::class)]
|
||||
public Dispatcher $dispatcher;
|
||||
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param int $fd
|
||||
@@ -83,7 +88,7 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect
|
||||
{
|
||||
$middlewares = MiddlewareManager::get($handler->callback);
|
||||
|
||||
$dispatcher = new Dispatcher($handler, $middlewares);
|
||||
$dispatcher = $this->dispatcher->setHandler($handler)->setMiddlewares($middlewares);
|
||||
|
||||
return $dispatcher->handle($PsrRequest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user