Files
email-unlimit/server/src/handlers/health.rs
T

28 lines
778 B
Rust

use crate::db;
use crate::AppState;
use axum::{
extract::State,
response::{IntoResponse, Json},
};
use serde_json::json;
/// 健康检查端点
pub async fn health_check(State(state): State<AppState>) -> impl IntoResponse {
let database = db::health_check(&state.pool).await.is_ok();
Json(
json!({"status": if database { "ok" } else { "unavailable" }, "capabilities": {
"database": database, "redis": state.redis_client.is_some(), "email": state.config.email.enabled
}}),
)
}
/// 获取服务器信息
pub async fn server_info() -> impl IntoResponse {
Json(json!({
"name": "email-unlimit-server",
"version": "0.1.0",
"status": "running",
"timestamp": chrono::Utc::now().timestamp()
}))
}