code: public function handle(ServerRequestInterface $request, ServerFrame $frame) : ResponseInterface
      {
          if ($this->flightRecorder) {
              $this->flightRecorder->getStopWatch()->start('server');
          }
  
          $response = $frame->next($request);
  
          // TODO: have a decorator service for the HtmlConverter that injects the debug bar
          if ($this->flightRecorder &&
              $this->flightRecorder->isRecordCurrentRequest() &&
              isset($response->getHeaders()['Content-Type'][0]) &&
              $response->getHeaders()['Content-Type'][0] === 'text/html'
          ) {
  
              $report = $this->flightRecorder->stop($response);
  
              $rendered = str_replace(
                  '</body>',
                  $this->flightRecorder->renderDebugBar($report) . '</body>',
                  (string) $response->getBody()
              );
  
              // TODO: avoid using "stream_for" as it is Guzzle specific. Have a $frame->responseFactory()->stream(...)
              return $response->withBody(stream_for($rendered));
          }
  
          return $response;
      }
docs: @param ServerRequestInterface $request
  @param ServerFrame            $frame
  
  @return ResponseInterface