feat(presentation): GET /health endpoint
This commit is contained in:
10
crates/presentation/src/handlers/health.rs
Normal file
10
crates/presentation/src/handlers/health.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use axum::{extract::State, Json};
|
||||
use crate::state::AppState;
|
||||
|
||||
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" },
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user