host = $name; $this->port = $port; $this->server = new HttpServer($name, $port, reuse_port: true); return $this; } public function handle(callable $callable): static { $this->handler = $callable; return $this; } public function start(): void { $this->server->handle('/', function ($request, $response) { Coroutine::create(function () use ($request, $response) { try { $handler = $this->handler; $handler(Request::loadFromSwooleRequest($request), $response); } catch (Throwable $exception) { $this->logger->critical((string) $exception); } }); }); $this->server->start(); } public function close(): bool { $this->server->shutdown(); return true; } }