Skip to content

Commit 604ac51

Browse files
committed
add healthcheck end point
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.
1 parent ffbab6c commit 604ac51

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/MetaCPAN/Web/Controller/Root.pm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ sub robots : Path("robots.txt") : Args(0) {
9393
} );
9494
}
9595

96+
sub healthcheck : Local : Args(0) {
97+
my ( $self, $c ) = @_;
98+
99+
$c->res->content_type('application/json');
100+
$c->stash( {
101+
template => 'healthcheck.tx',
102+
status => 'healthy',
103+
} );
104+
}
105+
96106
=head2 end
97107
98108
Attempt to render a view, if needed.

root/healthcheck.tx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[% { status => $status }.json() | raw %]

0 commit comments

Comments
 (0)