0 follower

Final Class Yiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpWorker

InheritanceYiisoft\Yii\Runner\RoadRunner\RoadRunnerHttpWorker

Method Details

Hide inherited methods

__construct() public method

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),
    );
}

            
respond() public method

public void respond ( \Psr\Http\Message\ResponseInterface $response )
$response \Psr\Http\Message\ResponseInterface

                public function respond(ResponseInterface $response): void
{
    $this->worker->respond($response);
}

            
respondWithError() public method

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;
}

            
waitRequest() public method

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;
    }
}