12 lines
462 B
Rust
12 lines
462 B
Rust
use axum::{extract::State, Json};
|
|
use crate::state::AppState;
|
|
|
|
#[utoipa::path(get, path = "/health", responses((status = 200, description = "Service health status")))]
|
|
pub async fn health_handler(State(s): State<AppState>) -> Json<serde_json::Value> {
|
|
let db_ok = s.users.list_with_stats().await.is_ok();
|
|
Json(serde_json::json!({
|
|
"status": if db_ok { "ok" } else { "degraded" },
|
|
"db": if db_ok { "connected" } else { "error" },
|
|
}))
|
|
}
|