$code, 'message' => $message, ], $extra)); } /** * Liest Request-Body als JSON. Gibt assoc-Array oder null bei Fehler. */ function v2_request_body_json(): ?array { $raw = file_get_contents('php://input'); if (!$raw) return null; $decoded = json_decode($raw, true); return is_array($decoded) ? $decoded : null; } /** * Pflicht-JSON-Body — bei fehlend/ungültig: 400 + exit. */ function v2_request_body_json_required(): array { $body = v2_request_body_json(); if (!$body) { v2_response_error(400, 'bad_request', 'JSON-Body fehlt oder ist ungültig.'); } return $body; }