-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [FIX] Исправлена мелкие проблемы с маршутизацией - [UPDATE] Изменён класс работы с базой данных на `illuminate/database` - [UPDATE] Изменён подход к маршрутизации - [NEW] Добавлен новый маршрут для поиска по значениям /search/{db_table}. Подробнее в документации - [NEW] Добавлен к каждой таблице новый вид маршрутизации /{db_table/{id} для метода запроса GET, чтобы получить лишь одну запись. Для таблицы post данный метод является расширенным. В нём парсятся категории и доп. поля
- Loading branch information
Showing
2,430 changed files
with
185,011 additions
and
2,006 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"version": "160.0.35", | ||
"version": "173.0.38", | ||
"name": "DLE API" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?php | ||
|
||
|
||
/** | ||
* Система кеширования запросов | ||
*/ | ||
|
268 changes: 127 additions & 141 deletions
268
upload/api/includes/CrudController.php
100644 → 100755
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
|
||
|
||
abstract class ErrorResponse { | ||
public static array $error_types | ||
= [ | ||
200 => "Успешный ответ", | ||
201 => "Запись успешно создана / обновлена", | ||
204 => "Запись успешно удалена", | ||
400 => "При создании / обновлении записи возникла ошибка", | ||
401 => "Неверный API-ключ или отсутствие прав доступа", | ||
404 => "Указанная запись не найдена", | ||
]; | ||
|
||
public static function error(ResponseInterface $response, int $errorNumber, ?string $errorMessage = null): ResponseInterface { | ||
$response->getBody()->write( | ||
json_encode( | ||
[ | ||
"error" => !in_array($errorNumber, [200, 201, 204]), | ||
"status" => $errorNumber, | ||
"description" => ErrorResponse::$error_types[$errorNumber], | ||
"message" => $errorMessage ?? errorResponse::$error_types[$errorNumber] | ||
], JSON_UNESCAPED_UNICODE | ||
) | ||
); | ||
|
||
return $response->withStatus($errorNumber)->withHeader('Content-Type', 'application/json; charset=UTF-8'); | ||
} | ||
|
||
public static function success(ResponseInterface $response, mixed $data = null, int $status = 201): ResponseInterface { | ||
$response->getBody()->write($data); | ||
return $response->withStatus($status)->withHeader('Content-Type', 'application/json; charset=UTF-8'); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.