feat: add GET /health endpoint for Docker/k8s liveness probes

This commit is contained in:
2026-05-12 02:05:37 +02:00
parent 6eeba2cf57
commit 5c918accbc

View File

@@ -18,6 +18,7 @@ pub fn build_router(state: AppState, ap_router: Router) -> Router {
let ap_router = ap_router.layer(GovernorLayer::new(ap_cfg)); let ap_router = ap_router.layer(GovernorLayer::new(ap_cfg));
Router::new() Router::new()
.route("/health", routing::get(health_handler))
.merge(html_routes(rate_limit)) .merge(html_routes(rate_limit))
.merge(api_routes(rate_limit)) .merge(api_routes(rate_limit))
.nest_service("/static", ServeDir::new("static")) .nest_service("/static", ServeDir::new("static"))
@@ -26,6 +27,10 @@ pub fn build_router(state: AppState, ap_router: Router) -> Router {
.merge(ap_router) .merge(ap_router)
} }
async fn health_handler() -> axum::Json<serde_json::Value> {
axum::Json(serde_json::json!({ "status": "ok" }))
}
fn per_minute(n: u64) -> Quota { fn per_minute(n: u64) -> Quota {
let n = NonZeroU32::new(n.clamp(1, u32::MAX as u64) as u32).unwrap(); let n = NonZeroU32::new(n.clamp(1, u32::MAX as u64) as u32).unwrap();
Quota::requests_per_minute(n) Quota::requests_per_minute(n)