Commit 5e18fc72 authored by Curtis Conard's avatar Curtis Conard Committed by Johan Cwiklinski
Browse files

Allow changing format with query param

parent 4dc5dc49
......@@ -47,12 +47,25 @@ $fallback_response_type = 'text/plain';
if (!isset($_SERVER['HTTP_ACCEPT']) || !in_array($_SERVER['HTTP_ACCEPT'], $valid_response_types, true)) {
$_SERVER['HTTP_ACCEPT'] = $fallback_response_type;
}
if ($_SERVER['HTTP_ACCEPT'] === 'text/plain') {
$format = $_SERVER['HTTP_ACCEPT'];
if (isset($_REQUEST['format'])) {
switch ($_REQUEST['format']) {
case 'json':
$format = 'application/json';
break;
case 'plain':
$format = 'text/plain';
break;
}
}
if ($format === 'text/plain') {
Toolbox::deprecated('Plain-text status output is deprecated please use the JSON format instead by specifically setting the Accept header to "application/json". In the future, JSON output will be the default.');
}
header('Content-type: ' . $_SERVER['HTTP_ACCEPT']);
header('Content-type: ' . $format);
if ($_SERVER['HTTP_ACCEPT'] === 'application/json') {
if ($format === 'application/json') {
echo json_encode(StatusChecker::getServiceStatus($_REQUEST['service'] ?? null, true, true));
} else {
echo StatusChecker::getServiceStatus($_REQUEST['service'] ?? null, true, false);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment