/**
* dispatchAssets.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function dispatchAssets($request, $next)
{
$assets = $request->get('_tracy_bar');
switch ($assets) {
case 'css':
$content = $this->debugbar->dispatchAssets();
$headers = ['content-type' => 'text/css; charset=utf-8', 'cache-control' => 'max-age=86400'];
break;
case 'js':
case 'assets':
$content = $this->debugbar->dispatchAssets();
$headers = ['content-type' => 'text/javascript; charset=utf-8', 'cache-control' => 'max-age=86400'];
break;
default:
$this->storeWrapper->start();
$this->storeWrapper->restore();
$content = $this->debugbar->dispatchContent();
$headers = ['content-type' => 'text/javascript; charset=utf-8'];
$this->storeWrapper->clean($assets)->close();
break;
}
return $this->responseFactory->make($content, 200, array_merge($headers, ['content-length' => strlen($content)]));
}