Initial commit: Slim Framework 4 API Retribusi dengan modular architecture
This commit is contained in:
35
src/Modules/Health/HealthRoutes.php
Normal file
35
src/Modules/Health/HealthRoutes.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Health;
|
||||
|
||||
use App\Support\ResponseHelper;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\App;
|
||||
|
||||
class HealthRoutes
|
||||
{
|
||||
/**
|
||||
* Register health check routes
|
||||
*
|
||||
* @param App $app
|
||||
* @return void
|
||||
*/
|
||||
public static function register(App $app): void
|
||||
{
|
||||
$app->get('/health', function (
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response
|
||||
): ResponseInterface {
|
||||
$data = [
|
||||
'status' => 'ok',
|
||||
'time' => time()
|
||||
];
|
||||
|
||||
return ResponseHelper::json($response, $data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
35
src/Modules/Health/Routes.php
Normal file
35
src/Modules/Health/Routes.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Health;
|
||||
|
||||
use App\Support\ResponseHelper;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\App;
|
||||
|
||||
class HealthRoutes
|
||||
{
|
||||
/**
|
||||
* Register health check routes
|
||||
*
|
||||
* @param App $app
|
||||
* @return void
|
||||
*/
|
||||
public static function register(App $app): void
|
||||
{
|
||||
$app->get('/health', function (
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response
|
||||
): ResponseInterface {
|
||||
$data = [
|
||||
'status' => 'ok',
|
||||
'time' => time()
|
||||
];
|
||||
|
||||
return ResponseHelper::json($response, $data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user