Skip to content

Commit

Permalink
skipping render envbar when response is not successful
Browse files Browse the repository at this point in the history
  • Loading branch information
devajmeireles committed Sep 18, 2024
1 parent 51da5d7 commit 6d601f1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Middleware/Injection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
namespace TallStackUi\EnvBar\Middleware;

use Closure;
use Illuminate\Http\Response;
use TallStackUi\EnvBar\Response\PreventInjection;
use TallStackUi\EnvBar\Response\Render;

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);
}
Expand Down

0 comments on commit 6d601f1

Please sign in to comment.