Final Class Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpWorker
| Inheritance | Yiisoft\ |
|---|
Public Methods
Method Details
| public mixed __construct ( \ | ||
| $container | \ |
|
| $worker | ?\ |
|
public function __construct(ContainerInterface $container, ?PSR7WorkerInterface $worker = null)
{
/** @psalm-var ResponseFactoryInterface $this->responseFactory */
$this->responseFactory = $container->get(ResponseFactoryInterface::class);
/** @psalm-var ErrorCatcher $this->errorCatcher */
$this->errorCatcher = $container->get(ErrorCatcher::class);
/** @psalm-var ErrorHandler $this->errorHandler */
$this->errorHandler = $container->get(ErrorHandler::class);
/** @psalm-suppress MixedArgument */
$this->worker = $worker ?? new PSR7Worker(
Worker::create(),
$container->get(ServerRequestFactoryInterface::class),
$container->get(StreamFactoryInterface::class),
$container->get(UploadedFileFactoryInterface::class),
);
}
| public void respond ( \ | ||
| $response | \ |
|
public function respond(ResponseInterface $response): void
{
$this->worker->respond($response);
}
| public \ | ||
| $throwable | Throwable | |
| $request | ?\ |
|
public function respondWithError(Throwable $throwable, ?ServerRequestInterface $request = null): ResponseInterface
{
if ($request === null) {
$errorData = $this->errorHandler->handle($throwable);
$response = $errorData->addToResponse($this->responseFactory->createResponse(Status::BAD_REQUEST));
} else {
$response = $this->errorCatcher->process($request, new ThrowableHandler($throwable));
}
$this->respond($response);
return $response;
}
| public \ |
public function waitRequest(): ServerRequestInterface|Throwable|null
{
try {
return $this->worker->waitRequest()?->withAttribute('applicationStartTime', microtime(true));
} catch (Throwable $t) {
return $t;
}
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.