- sogoctl: supervisor avec health checks et restart auto - sogoway: gateway HTTP, auth JWT, routing par hostname - sogoms-db: microservice MariaDB avec pool par application - Protocol IPC Unix socket JSON length-prefixed - Config YAML multi-application (prokov) - Deploy script pour container Alpine gw3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Gestion des réponses JSON
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
class Response
|
|
{
|
|
public static function json(mixed $data, int $code = 200): void
|
|
{
|
|
http_response_code($code);
|
|
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
exit;
|
|
}
|
|
|
|
public static function success(mixed $data = null, string $message = 'OK', int $code = 200): void
|
|
{
|
|
self::json([
|
|
'success' => true,
|
|
'message' => $message,
|
|
'data' => $data,
|
|
], $code);
|
|
}
|
|
|
|
public static function error(string $message, int $code = 400, mixed $errors = null): void
|
|
{
|
|
$response = [
|
|
'success' => false,
|
|
'message' => $message,
|
|
];
|
|
|
|
if ($errors !== null) {
|
|
$response['errors'] = $errors;
|
|
}
|
|
|
|
self::json($response, $code);
|
|
}
|
|
|
|
public static function notFound(string $message = 'Resource not found'): void
|
|
{
|
|
self::error($message, 404);
|
|
}
|
|
|
|
public static function unauthorized(string $message = 'Unauthorized'): void
|
|
{
|
|
self::error($message, 401);
|
|
}
|
|
}
|