Развитие бека
1. Создание БД 2. Создание бека 3. Пока создали класс юзера
This commit is contained in:
23
backend/app/restAPI/class_restApi.php
Normal file
23
backend/app/restAPI/class_restApi.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
class RestApi {
|
||||
|
||||
// Получить данные из JSON запроса
|
||||
public static function getInput(): array {
|
||||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json, true);
|
||||
|
||||
return $data ?? [];
|
||||
}
|
||||
|
||||
// Отправить JSON ответ
|
||||
public static function response($data, int $code = 200): void {
|
||||
http_response_code($code);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user