Expand description
The rocket_healthz crate provides a fairing to easily add
a /healthz endpoint to your Rocket
project. The endpoint responds with HTTP 200 and the plain
text OK. You can use it for health checks when
you want to verify that the server is running.
#[macro_use] extern crate rocket;
use rocket_healthz::Healthz;
#[get("/")]
fn hello() -> &'static str {
"Hello, world!"
}
#[launch]
fn rocket() -> _ {
rocket::build()
.mount("/", routes![hello])
// vvv - this is the key part, attaching our fairing
.attach(Healthz::fairing())
}§Why?
This is just syntatic sugar for manually writing and mounting
a /healthz route, which is already a trivial function:
#[macro_use] extern crate rocket;
#[get("/healthz")]
fn healthz() -> &'static str {
"OK"
}Structs§
- Healthz
/healthzfairing