Final Class Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpWorker
| Inheritance | Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpWorker |
|---|
Public Methods
Method Details
| public mixed __construct ( \Psr\Container\ContainerInterface $container, \Spiral\RoadRunner\Http\PSR7WorkerInterface|null $worker = null ) | ||
| $container | \Psr\Container\ContainerInterface | |
| $worker | \Spiral\RoadRunner\Http\PSR7WorkerInterface|null | |
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 ( \Psr\Http\Message\ResponseInterface $response ) | ||
| $response | \Psr\Http\Message\ResponseInterface | |
public function respond(ResponseInterface $response): void
{
$this->worker->respond($response);
}
| public \Psr\Http\Message\ResponseInterface respondWithError ( Throwable $throwable, \Psr\Http\Message\ServerRequestInterface|null $request = null ) | ||
| $throwable | Throwable | |
| $request | \Psr\Http\Message\ServerRequestInterface|null | |
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 \Psr\Http\Message\ServerRequestInterface|Throwable|null waitRequest ( ) |
public function waitRequest(): ServerRequestInterface|Throwable|null
{
try {
return $this->worker->waitRequest()?->withAttribute('applicationStartTime', microtime(true));
} catch (Throwable $t) {
return $t;
}
}
Signup or Login in order to comment.