5 unstable releases
0.5.0 | May 21, 2024 |
---|---|
0.5.0-rc.2 | Dec 31, 2023 |
0.5.0-rc.1 | Dec 1, 2023 |
0.2.0 | Jan 24, 2021 |
0.1.0 | Aug 25, 2020 |
#473 in HTTP server
58 downloads per month
6KB
53 lines
rocket_healthz
The rocket_healthz
crate provides a fairing to easily add a /healthz
endpoint to your Rocket project.
License
rocket_healthz is (C) 2020-2021, 2023 Kunal Mehta, released under the Apache 2.0 license, see LICENSE for details.
lib.rs
:
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"
}
Dependencies
~15–46MB
~786K SLoC