Add support for JSON listing #1

Merged
Francesco Siddi merged 7 commits from json-view into develop 2023-11-01 12:08:09 +01:00
Showing only changes of commit 8fbca889a5 - Show all commits

View File

@ -20,12 +20,12 @@ function renderDownloadResponseAsJSON($lister) {
$data = [ 'error' => 'Missing supported format version, for example v=1']; $data = [ 'error' => 'Missing supported format version, for example v=1'];
echo json_encode( $data ); echo json_encode( $data );
http_response_code(400); http_response_code(400);
exit; return;
} }
$builds = $lister->getBuilds(); $builds = $lister->getBuilds();
$renderer = new BuildsRenderer($builds); $renderer = new BuildsRenderer($builds);
$renderer->renderJSON(); $renderer->renderJSON();
exit; return;
} }
function renderDownloadResponseAsHTML($lister) { function renderDownloadResponseAsHTML($lister) {
@ -55,6 +55,7 @@ function handleDownloadRequest() {
// Check if we are requesting a JSON formatted view. // Check if we are requesting a JSON formatted view.
if (isset($_GET['format']) && $_GET['format'] == 'json') { if (isset($_GET['format']) && $_GET['format'] == 'json') {
renderDownloadResponseAsJSON($lister); renderDownloadResponseAsJSON($lister);
return;
} }
renderDownloadResponseAsHTML($lister); renderDownloadResponseAsHTML($lister);