-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a /healthcheck end point, returning a simple JSON structure. Use a template rather than normal JSON encoding to ensure that the template engine is working correctly. In the future, this could be extended to check that the API is available, but for now a simple check that just the web server is running is good enough.
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[% { status => $status }.json() | raw %] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |