src/Leevel/Debug/Debug.php
public function handle(IRequest $request, IResponse $response): void
    {
        if (!$this->enabled) {
            return;
        }

        if (
                $request->isJson() ||
                $response instanceof ApiResponse ||
                $response instanceof JsonResponse ||
                $response->isJson()
            ) {
            if ($this->option['json'] && is_array($data = $response->getData())) {
                $jsonRenderer = $this->getJsonRenderer();

                if (array_values($data) !== $data) {
                    $data[':trace'] = $jsonRenderer->render();
                } else {
                    $data[] = [':trace' => $jsonRenderer->render()];
                }

                $response->setData($data);
            }
        } elseif (!($response instanceof RedirectResponse)) {
            if ($this->option['javascript']) {
                $javascriptRenderer = $this->getJavascriptRenderer('/debugbar');
                $response->appendContent(
                    $javascriptRenderer->renderHead().$javascriptRenderer->render()
                );
            }

            if ($this->option['console']) {
                $consoleRenderer = $this->getConsoleRenderer();
                $response->appendContent($consoleRenderer->render());
            }
        }
    }
public function handle(IRequest $request, IResponse $response): void
    {
        if (!$this->enabled) {
            return;
        }

        if (
                $request->isJson() ||
                $response instanceof ApiResponse ||
                $response instanceof JsonResponse ||
                $response->isJson()
            ) {
            if ($this->option['json'] && is_array($data = $response->getData())) {
                $jsonRenderer = $this->getJsonRenderer();

                if (array_values($data) !== $data) {
                    $data[':trace'] = $jsonRenderer->render();
                } else {
                    $data[] = [':trace' => $jsonRenderer->render()];
                }

                $response->setData($data);
            }
        } elseif (!($response instanceof RedirectResponse)) {
            if ($this->option['javascript']) {
                $javascriptRenderer = $this->getJavascriptRenderer('/debugbar');
                $response->appendContent(
                    $javascriptRenderer->renderHead().$javascriptRenderer->render()
                );
            }

            if ($this->option['console']) {
                $consoleRenderer = $this->getConsoleRenderer();
                $response->appendContent($consoleRenderer->render());
            }
        }
    }
响应.

@param \Leevel\Http\IRequest  $request
@param \Leevel\Http\IResponse $response