#rocket-web #health-check

rocket_healthz

Add /healthz endpoint to a Rocket web server

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

Download history 10/week @ 2024-07-28 17/week @ 2024-08-04 54/week @ 2024-08-25 2/week @ 2024-09-01 23/week @ 2024-09-08 33/week @ 2024-09-15 9/week @ 2024-09-22 51/week @ 2024-09-29 122/week @ 2024-10-06 19/week @ 2024-10-13 1/week @ 2024-10-20 34/week @ 2024-11-03

58 downloads per month

Apache-2.0

6KB
53 lines

rocket_healthz

crates.io docs.rs pipeline status coverage report

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