Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Handle the response with the kernel before shutdown (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x authored Jan 29, 2025
1 parent 621a3dd commit e7a15b8
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Roots/Acorn/Application/Concerns/Bootable.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,17 @@ protected function registerRequestHandler(
ob_start();

remove_action('shutdown', 'wp_ob_end_flush_all', 1);
add_action('shutdown', fn () => $this->handleRequest($request), 100);
}

/**
* Handle the request.
*/
public function handleRequest(\Illuminate\Http\Request $request): void
{
$kernel = $this->make(HttpKernelContract::class);

$response = $kernel->handle($request);

$response->send();
add_action('shutdown', function () use ($kernel, $request, $response) {
$response->send();

$kernel->terminate($request, $response);
$kernel->terminate($request, $response);

exit((int) $response->isServerError());
exit((int) $response->isServerError());
}, 100);
}
}

0 comments on commit e7a15b8

Please sign in to comment.