Skip to content

Commit 42420dc

Browse files
committed
move health endpoint behind authentication and created basic ping endpoint
1 parent e449595 commit 42420dc

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

app/Providers/RestifyServiceProvider.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Providers;
44

55
use App\Http\Controllers\Api\V1\HealthController;
6+
use App\Http\Controllers\Api\V1\PingController;
67
use Binaryk\LaravelRestify\Bootstrap\RoutesBoot;
78
use Binaryk\LaravelRestify\Restify;
89
use 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();

0 commit comments

Comments
 (0)