Skip to content

Configuration

health()

health() — returns struct

Available in: mapper Category: Routing

Register a health check route at /health (or a custom path). Returns a JSON response with status and timestamp by default, or delegates to a custom controller action. This is useful for container orchestration (Kubernetes liveness/readiness probes), load balancer health checks, and monitoring tools.

NameTypeRequiredDefaultDescription
tostringnowheels#healthSet controller##action combination for a custom health check handler. If not provided, a default handler returns {"status":"ok","timestamp":"..."}.
pathstringnohealthOverride the URL path. Defaults to "health".
namestringnohealthOverride the route name. Defaults to "health".
<cfscript>

mapper()
    // 1. Register the default health check route at /health.
    // Responds with {"status":"ok","timestamp":"..."} — no controller needed.
    .health()

    .root(to="home##index")
    .wildcard()
.end();

// 2. Override the URL path and route name.
// Accessible at /healthz instead of /health.
mapper()
    .health(path="healthz", name="healthz")
    .root(to="home##index")
.end();

// 3. Delegate to a custom controller action for advanced health checks
// (e.g. database ping, cache connectivity).
mapper()
    .health(to="system##health")
    .root(to="home##index")
.end();

</cfscript>