public class HealthCheckHandler extends Object implements Handler
This handler should be bound to an application path, and most likely only for the GET method…
import ratpack.codahale.healthcheck.HealthCheckHandler; chain instanceof ratpack.handling.Chain; chain.get("health-checks/:name?", new HealthCheckHandler());
The handler can render the result of all of the health checks or an individual health check, depending on the presence of a path token. The path token provides the name of the health check to render. If the path token is not present, all health checks will be rendered. The token name to use can be provided as the construction argument to this handler. The default token name is "name" and is used if the no-arg constructor is used.
If the token is present, the health check whose name is the value of the token will be rendered. If no health check exists by that name, the client will receive a 404.
When a single health check is selected (by presence of the path token) the corresponding HealthCheck.Result
is rendered
.
When rendering all health checks a HealthCheckResults
is rendered
.
The CodaHaleHealthCheckModule
installs renderers for these two types that simply renders to the toString()
as plain text.
If you wish to change the representation, to JSON for example, you can register your own renderers for these types after registering the
CodaHaleHealthCheckModule
.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_HEALTH_CHECK_NAME_TOKEN
The default path token used to identify a particular health check: "name"
|
Constructor and Description |
---|
HealthCheckHandler() |
HealthCheckHandler(String healthCheckNameToken) |
public static final String DEFAULT_HEALTH_CHECK_NAME_TOKEN
HealthCheckHandler()
,
Constant Field Valuespublic HealthCheckHandler()
public HealthCheckHandler(String healthCheckNameToken)
public void handle(Context context) throws Exception
Handler
handle
in interface Handler
context
- The context to handleException
- if anything goes wrong (exception will be implicitly passed to the context's Context.error(Throwable)
method)