NAME
PAGI::Middleware::Healthcheck - Health check endpoint middleware
SYNOPSIS
use PAGI::Middleware::Builder;
my $app = builder {
enable 'Healthcheck',
path => '/health',
checks => {
database => sub { check_db_connection() },
cache => sub { check_redis() },
};
$my_app;
};
DESCRIPTION
PAGI::Middleware::Healthcheck provides a health check endpoint for load balancers and monitoring systems. Returns JSON status information.
CONFIGURATION
path (default: '/health')
Path for the health check endpoint.
live_path (optional)
Separate path for liveness probe (always returns 200 if server is running).
ready_path (optional)
Separate path for readiness probe (runs all checks).
checks (optional)
Hashref of named health checks. Each check is a coderef that returns true (healthy) or false (unhealthy), or throws an exception.
include_details (default: 1)
Include individual check results in response.
RESPONSE FORMAT
Health check responses are JSON:
{
"status": "ok",
"timestamp": 1234567890,
"checks": {
"database": { "status": "ok" },
"cache": { "status": "error", "message": "Connection refused" }
}
}
HTTP STATUS CODES
200 - All checks passed
503 - One or more checks failed
KUBERNETES PROBES
Configure separate endpoints for Kubernetes:
enable 'Healthcheck',
path => '/health',
live_path => '/healthz',
ready_path => '/ready',
checks => { db => sub { ... } };
SEE ALSO
PAGI::Middleware - Base class for middleware