5.4.0
Restructure New Journal entries Colour tabs update with wind
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// ─── SunScope — JSON response helpers ────────────────────────────────────
|
||||
|
||||
function json_out(array $data, int $status = 200): void {
|
||||
http_response_code($status);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
exit;
|
||||
}
|
||||
|
||||
function json_error(string $message, int $status = 400): void {
|
||||
json_out(['ok' => false, 'error' => $message], $status);
|
||||
}
|
||||
|
||||
function json_body(): array {
|
||||
$body = json_decode(file_get_contents('php://input'), true);
|
||||
return is_array($body) ? $body : [];
|
||||
}
|
||||
|
||||
function require_method(string $method): void {
|
||||
if ($_SERVER['REQUEST_METHOD'] !== $method) {
|
||||
json_error('Method not allowed', 405);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user