//! GET /api/v1/ping: cheap authenticated liveness. //! //! `/healthz` does not validate a token, so a consolidator cannot use it to //! prove "API running with our credentials". This route sits behind the same //! auth layer as every other `/api/v1` route. use axum::routing::get; use axum::{Json, Router}; use crate::openapi::Health; use crate::state::AppState; pub fn routes() -> Router { Router::new().route("/ping", get(ping)) } #[utoipa::path( get, path = "/api/v1/ping", operation_id = "ping", tag = "health", summary = "Authenticated liveness", description = "Cheap authenticated check. A consolidator calls it to prove that the API \ answers with its credential: a 401 still means the API is running.", responses( (status = 200, body = Health, description = "The API is running and the token is valid"), (status = 401, body = crate::openapi::ErrorBody, description = "Missing or unknown bearer token"), (status = 503, body = crate::openapi::ErrorBody, description = "The token database is unavailable"), ) )] pub(crate) async fn ping() -> Json { Json(serde_json::json!({ "status": "ok", "version": crate::VERSION, })) } #[cfg(test)] #[path = "ping_tests.rs"] mod tests;