Added an open healthcheck API endpoint.
This commit is contained in:
24
src/API/System/HealthCheck.php
Normal file
24
src/API/System/HealthCheck.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\API\System;
|
||||
|
||||
use App\Libs\Attributes\Route\Get;
|
||||
use App\Libs\HTTP_STATUS;
|
||||
use Psr\Http\Message\ResponseInterface as iResponse;
|
||||
use Psr\Http\Message\ServerRequestInterface as iRequest;
|
||||
|
||||
final class HealthCheck
|
||||
{
|
||||
public const string URL = '%{api.prefix}/system/healthcheck';
|
||||
|
||||
#[Get(self::URL . '[/]', name: 'system.healthcheck')]
|
||||
public function __invoke(iRequest $request): iResponse
|
||||
{
|
||||
return api_response(HTTP_STATUS::HTTP_OK, [
|
||||
'status' => 'ok',
|
||||
'message' => 'System is healthy',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Libs\Middlewares;
|
||||
|
||||
use App\API\System\HealthCheck;
|
||||
use App\Libs\Config;
|
||||
use App\Libs\HTTP_STATUS;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
@@ -17,8 +18,7 @@ final class APIKeyRequiredMiddleware implements MiddlewareInterface
|
||||
public const string KEY_NAME = 'apikey';
|
||||
|
||||
private const array OPEN_ROUTES = [
|
||||
\App\API\Webhooks\Index::URL,
|
||||
\App\API\System\HealthCheck::URL,
|
||||
HealthCheck::URL,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user