diff --git a/Dockerfile b/Dockerfile index 9d51dcf4b7..08662d46d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,8 @@ RUN <res->content_type('application/json'); + $c->stash( { + template => 'healthcheck.tx', + status => 'healthy', + } ); +} + =head2 end Attempt to render a view, if needed. diff --git a/root/healthcheck.tx b/root/healthcheck.tx new file mode 100644 index 0000000000..1e3babd029 --- /dev/null +++ b/root/healthcheck.tx @@ -0,0 +1 @@ +[% { status => $status }.json() | raw %] diff --git a/t/controller/healthcheck.t b/t/controller/healthcheck.t new file mode 100644 index 0000000000..a916c9b49f --- /dev/null +++ b/t/controller/healthcheck.t @@ -0,0 +1,19 @@ +use strict; +use warnings; +use lib 't/lib'; + +use Cpanel::JSON::XS qw( decode_json ); +use MetaCPAN::Web::Test qw( app GET test_psgi ); +use Test::More; + +test_psgi app, sub { + my $cb = shift; + ok( my $res = $cb->( GET '/healthcheck' ), 'GET /healthcheck' ); + is( $res->code, 200, 'code 200' ); + is $res->header('Content-Type'), 'application/json', + 'correct Content-Type'; + my $data = decode_json( $res->content ); + is $data->{status}, 'healthy', 'has correct status'; +}; + +done_testing;