| Crates.io | rocket_health |
| lib.rs | rocket_health |
| version | 0.2.0 |
| created_at | 2025-07-12 14:05:50.339351+00 |
| updated_at | 2025-09-14 11:12:52.725594+00 |
| description | Drop-in /health route for Rocket APIs with uptime and rolling average latency metrics. |
| homepage | |
| repository | https://github.com/juliengriffoul/rocket_health |
| max_upload_size | |
| id | 1749330 |
| size | 54,482 |
๐ง Drop-in
/healthroute for Rocket APIs with uptime and rolling average latency metrics.
/health route returning structured JSONExample response:
{
"status": "ok",
"uptime_seconds": 432.123,
"mean_latency_seconds": 0.0054
}
Add to your Cargo.toml:
[dependencies]
rocket_health = "0.1"
rocket = { version = "0.5", features = ["json"] }
#[macro_use] extern crate rocket;
use rocket_health::mount_health_route;
#[launch]
fn rocket() -> _ {
let rocket = rocket::build();
mount_health_route(rocket)
}
The /health route is now available:
GET /health
Returns uptime and latency in seconds (float). Latency is computed using a sliding window of the last 100 requests.
You can unit test the handler or compute test coverage using cargo-tarpaulin:
cargo install cargo-tarpaulin
cargo tarpaulin --out Html --ignore-tests --line --target-dir tarpaulin-target/ --skip-clean