Add initial Axum application and admin backends

This commit is contained in:
2026-11-30 18:02:10 +08:00
parent 698f126033
commit 296fb9b1b7
9 changed files with 465 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
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<Arc<db::Connection>>) -> StatusCode {
match tokio::time::timeout(Duration::from_secs(2), db.revision()).await {
Ok(Ok(_)) => StatusCode::NO_CONTENT,
_ => StatusCode::SERVICE_UNAVAILABLE,
}
}