| Crates.io | axum-health |
| lib.rs | axum-health |
| version | 0.1.2 |
| created_at | 2025-02-17 22:05:21.348284+00 |
| updated_at | 2025-02-18 04:48:39.990932+00 |
| description | Spring Boot like health indicators. |
| homepage | https://github.com/alanbaumgartner/axum-health |
| repository | https://github.com/alanbaumgartner/axum-health |
| max_upload_size | |
| id | 1559381 |
| size | 138,607 |
Spring Boot -like health indicators.
#[tokio::main]
async fn main() {
let pool = SqlitePool::connect("test.db").await.unwrap();
// Clone the pool!
let indicator = DatabaseHealthIndicator::new("sqlite".to_owned(), pool.clone());
let router = Router::new()
.route("/health", get(axum_health::health))
// Create a Health layer and add the indicator
.layer(Health::builder().with_indicator(indicator).build())
.with_state(pool);
let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, router.into_make_service())
.await
.unwrap()
}
The health endpoint will respond
{
"status": "UP",
"components": {
"sqlite": {
"status": "UP"
}
}
}
Checkout the examples