0 follower

Final Class Yiisoft\Yii\Debug\Api\Debug\Middleware\DebugHeaders

InheritanceYiisoft\Yii\Debug\Api\Debug\Middleware\DebugHeaders
ImplementsPsr\Http\Server\MiddlewareInterface

Adds debug headers to response. Information from these headers may be used to request information about the current request as it is done in the debug toolbar.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Yiisoft\Router\UrlGeneratorInterface $urlGenerator, \Yiisoft\Yii\Debug\Debugger|null $debugger null )
$urlGenerator \Yiisoft\Router\UrlGeneratorInterface
$debugger \Yiisoft\Yii\Debug\Debugger|null

                public function __construct(
    private UrlGeneratorInterface $urlGenerator,
    private ?Debugger $debugger = null,
) {
}

            
process() public method

public \Psr\Http\Message\ResponseInterface process ( \Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler )
$request \Psr\Http\Message\ServerRequestInterface
$handler \Psr\Http\Server\RequestHandlerInterface

                public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
    $response = $handler->handle($request);
    if ($this->debugger === null || !$this->debugger->isActive()) {
        return $response;
    }
    $link = $this->urlGenerator->generate('debug/api/view', ['id' => $this->debugger->getId()]);
    return $response
        ->withHeader('X-Debug-Id', $this->debugger->getId())
        ->withHeader('X-Debug-Link', $link);
}