From 6d601f1ff2a515ede3ef3e5fad7f32b69d3d1d59 Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Wed, 18 Sep 2024 14:51:41 -0300 Subject: [PATCH] skipping render envbar when response is not successful --- src/Middleware/Injection.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Middleware/Injection.php b/src/Middleware/Injection.php index e1ed0f9..96d658b 100644 --- a/src/Middleware/Injection.php +++ b/src/Middleware/Injection.php @@ -3,6 +3,7 @@ namespace TallStackUi\EnvBar\Middleware; use Closure; +use Illuminate\Http\Response; use TallStackUi\EnvBar\Response\PreventInjection; use TallStackUi\EnvBar\Response\Render; @@ -10,11 +11,16 @@ class Injection { public function handle($request, Closure $next) // @pest-ignore-type { + /** @var Response $response */ + $response = $next($request); + if (app(PreventInjection::class, ['request' => $request])->aborted()) { - return $next($request); + return $response; } - $response = $next($request); + if (! $response->isSuccessful()) { + return $response; + } return app(Render::class)->handle($response); }