2024-06-28 18:28:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
2024-07-03 13:20:39 +00:00
|
|
|
$routes = [
|
|
|
|
'' => function () {
|
|
|
|
header('Location: /api/status');
|
|
|
|
exit();
|
|
|
|
},
|
|
|
|
|
2024-07-27 12:07:27 +00:00
|
|
|
'i18n' => function () {
|
2024-07-05 11:04:25 +00:00
|
|
|
global $path;
|
|
|
|
return match ($path[2]) {
|
|
|
|
'languages' => [
|
|
|
|
"response" => [
|
|
|
|
'success' => true,
|
|
|
|
'status_code' => 200
|
|
|
|
],
|
|
|
|
'body' => [
|
|
|
|
'current' => $_SESSION['lang'],
|
|
|
|
'languages' => LANGAUGES
|
|
|
|
]
|
|
|
|
],
|
|
|
|
default => 404,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2024-07-03 13:20:39 +00:00
|
|
|
'status' => function () {
|
|
|
|
http_response_code(200);
|
|
|
|
|
|
|
|
return [
|
|
|
|
'response' => [
|
|
|
|
'success' => true,
|
|
|
|
'status_code' => 200
|
|
|
|
],
|
|
|
|
'body' => [
|
|
|
|
'message' => 'Science compels us to explode the sun!',
|
|
|
|
'time' => time()
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
2024-06-28 18:28:28 +00:00
|
|
|
];
|
|
|
|
|
2024-07-03 13:20:39 +00:00
|
|
|
if (array_key_exists($path[1], $routes)) {
|
|
|
|
$res = $routes[$path[1]]();
|
|
|
|
echo json_encode($res, JSON_PRETTY_PRINT);
|
|
|
|
} else {
|
|
|
|
echo json_encode([
|
|
|
|
"response" => [
|
|
|
|
"success" => false,
|
|
|
|
"status_code" => 404
|
|
|
|
],
|
|
|
|
'body' => [
|
|
|
|
'message' => 'That endpoint could not be found.'
|
|
|
|
]
|
|
|
|
], JSON_PRETTY_PRINT);
|
|
|
|
}
|