diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index af3285d3..683914aa 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -545,6 +545,10 @@ public function modifyResponse($request, $response) } } + if ($app['config']->get('debugbar.clockwork')) { + $this->addClockworkHeaders($response); + } + // Stop further rendering (on subrequests etc) $this->disable(); @@ -821,4 +825,11 @@ protected function selectStorage(DebugBar $debugbar) $debugbar->setStorage($storage); } } + + protected function addClockworkHeaders($response) + { + $response->headers->set('X-Clockwork-Id', $this->getCurrentRequestId(), true); + $response->headers->set('X-Clockwork-Version', 1, true); + $response->headers->set('X-Clockwork-Path','/_debugbar/clockwork/', true); + } } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 04765986..77ab118f 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -107,11 +107,6 @@ public function boot() $debugbar->boot(); $kernel = $this->app['Illuminate\Contracts\Http\Kernel']; - - if ($this->app['config']->get('debugbar.clockwork')) { - $kernel->pushMiddleware('Barryvdh\Debugbar\Support\Clockwork\Middleware'); - } - $kernel->pushMiddleware('Barryvdh\Debugbar\Middleware\Debugbar'); } diff --git a/src/Support/Clockwork/Middleware.php b/src/Support/Clockwork/Middleware.php deleted file mode 100644 index b1c8c5ad..00000000 --- a/src/Support/Clockwork/Middleware.php +++ /dev/null @@ -1,69 +0,0 @@ -app = $app; - $this->exceptionHandler = $exceptionHandler; - } - - /** - * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed - */ - public function handle($request, Closure $next) - { - /** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */ - $debugbar = $this->app['debugbar']; - - try { - /** @var \Illuminate\Http\Response $response */ - $response = $next($request); - } catch (\Exception $e) { - $debugbar->addException($e); - - $this->exceptionHandler->report($e); - $response = $this->exceptionHandler->render($request, $e); - } - - if ($request->is('_debugbar*') || $request->is('*clockwork*')) { - return $response; - } - - $response->headers->set('X-Clockwork-Id', $debugbar->getCurrentRequestId(), true); - $response->headers->set('X-Clockwork-Version', 1, true); - $response->headers->set('X-Clockwork-Path','/_debugbar/clockwork/', true); - - - return $debugbar->modifyResponse($request, $response); - - } -}