use std::{sync::Arc, time::Duration}; use axum::{Router, extract::State, http::StatusCode, routing::get}; pub fn router(db: db::Connection) -> Router { Router::new() .route("/healthz", get(|| async { StatusCode::NO_CONTENT })) .route("/readyz", get(readiness)) .with_state(Arc::new(db)) } async fn readiness(State(db): State>) -> StatusCode { match tokio::time::timeout(Duration::from_secs(2), db.revision()).await { Ok(Ok(_)) => StatusCode::NO_CONTENT, _ => StatusCode::SERVICE_UNAVAILABLE, } }