Fast.Plug.Heartbeat (Fast v0.11.0)
View SourceA plug for responding to heartbeat requests.
This plug responds with a successful status to GET or HEAD requests at a
specific path so that clients can check if a server is alive.
The response that this plug sends is a 200 OK response with body OK. By
default, the path that responds to the heartbeat is /healthz, but it
can be configured.
Note that this plug halts the connection. This is done so that it can be
plugged near the top of a plug pipeline and catch requests early so that
subsequent plugs don't have the chance to tamper the connection.
Read more about halting connections in the docs for
Plug.Builder.
Options
The following options can be used when calling plug HeartbeatPlug.
:path- a string expressing the path on whichHeartbeatPlugwill be mounted to respond to heartbeat requests:json- a boolean which determines whether the response will be anapplication/jsonresponse (iftrue) or a regular response.
Examples
defmodule MyServer do
use Plug.Builder
plug Fast.Plug.Heartbeat
# ... rest of the pipeline
endUsing a custom heartbeat path is easy:
defmodule MyServer do
use Plug.Builder
plug Fast.Plug.Heartbeat, path: "/heartbeat"
# ... rest of the pipeline
end
Summary
Functions
Callback implementation for Plug.call/2.
Callback implementation for Plug.init/1.