Something went wrong. Try again.
A small api and web interface to lookup some general information about ATProto users
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859use axum::{Json, http::StatusCode};use serde_json::{json, Value};
use crate::cache::redis::get_redis_manager;
#[utoipa::path( get, path = "/health", tag = "misc", responses( ( status = 200, description = "Completely Healthy", body = serde_json::Value, example = json!({ "overall": "healthy", "services": { "api": true, "redis": true, } }) ), ( status = 503, description = "Unhealthy: one or more internal systems are unreachable/unhealthy.", body = serde_json::Value, example = json!({ "overall": "unhealthy", "services": { "api": true, "redis": false, } }) ), ))]pub async fn fetch_health_data() -> (StatusCode, Json<Value>) { let mut overall = "healthy";
let api = true;
let response: Option<String> = redis::cmd("PING").query_async(&mut get_redis_manager().await).await.ok(); let redis_status: bool; if let Some("PONG") = response.as_deref() { redis_status = true; } else { redis_status = false; overall = "unhealthy"; } ( if overall == "unhealthy" { StatusCode::SERVICE_UNAVAILABLE } else { StatusCode::OK }, Json(json!({ "overall": overall, "services": { "api": api, "redis": redis_status, } })) )}