From 1cbbc6c52c272efb1721257ae64da35e38efc9f8 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 14 Feb 2019 01:18:31 +0100 Subject: [PATCH] Serialize data as JSON with `Accept: application/json` Similar to #607. According to the Catalyst[1] docs it's possible to specify a data structure that is supposed to be serialized when requesting i.e. a JSON response. [1] https://metacpan.org/pod/Catalyst::Controller::REST#status_ok --- src/lib/Hydra/Controller/Root.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 146c37a4..424f8d7a 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -197,6 +197,7 @@ sub machines :Local Args(0) { "where busy != 0 order by machine, stepnr", { Slice => {} }); $c->stash->{template} = 'machine-status.tt'; + $self->status_ok($c, entity => $c->stash->{machines}); } @@ -344,7 +345,9 @@ sub evals :Local Args(0) { $c->stash->{page} = $page; $c->stash->{resultsPerPage} = $resultsPerPage; $c->stash->{total} = $evals->search({hasnewbuilds => 1})->count; - $c->stash->{evals} = getEvals($self, $c, $evals, ($page - 1) * $resultsPerPage, $resultsPerPage) + $c->stash->{evals} = getEvals($self, $c, $evals, ($page - 1) * $resultsPerPage, $resultsPerPage); + + $self->status_ok($c, entity => $c->stash->{evals}); }