File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Http \Controllers \Api \V1 ;
4+
5+ use App \Http \Controllers \Controller ;
6+ use Illuminate \Http \JsonResponse ;
7+
8+ class PingController extends Controller
9+ {
10+ /**
11+ * Public, unauthenticated liveness probe. Confirms the application is
12+ * up and serving requests.
13+ */
14+ public function __invoke (): JsonResponse
15+ {
16+ return response ()->json (['status ' => 'ok ' ]);
17+ }
18+ }
Original file line number Diff line number Diff line change 33namespace App \Providers ;
44
55use App \Http \Controllers \Api \V1 \HealthController ;
6+ use App \Http \Controllers \Api \V1 \PingController ;
67use Binaryk \LaravelRestify \Bootstrap \RoutesBoot ;
78use Binaryk \LaravelRestify \Restify ;
89use Binaryk \LaravelRestify \RestifyApplicationServiceProvider ;
@@ -18,10 +19,15 @@ protected function gate(): void
1819
1920 protected function routes (): void
2021 {
21- // v1 custom endpoints that are not Restify repositories. The health
22- // endpoint is intentionally public (no auth middleware).
22+ // v1 custom endpoints that are not Restify repositories.
2323 Route::prefix ('api/v1 ' )->group (function (): void {
24- Route::get ('health ' , HealthController::class)->name ('v1.health ' );
24+ // Public, unauthenticated liveness probe.
25+ Route::get ('ping ' , PingController::class)->name ('v1.ping ' );
26+
27+ // Health check requires authentication (exposes subsystem status).
28+ Route::get ('health ' , HealthController::class)
29+ ->middleware ('auth:sanctum ' )
30+ ->name ('v1.health ' );
2531 });
2632
2733 parent ::routes ();
You can’t perform that action at this time.
0 commit comments