Skip to content

alanbaumgartner/axum-health

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

axum-health

Spring Boot-like health indicators.

Usage

#[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

About

Spring Boot like health inidicators for axum

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published