//! Health check routes
//!
//! Routes:
//! GET /health — health check
//! GET /health/live — liveness probe
//! GET /health/ready — readiness probe
use actix_web::{web, HttpResponse};
/// Health check handler — returns 200 OK
pub async fn health() -> HttpResponse {
HttpResponse::Ok().json(serde_json::json!({
"status": "ok",
"service": env!("CARGO_PKG_NAME")
}))
}
/// Liveness probe — Kubernetes-compatible
pub async fn liveness() -> HttpResponse {
HttpResponse::Ok().json(serde_json::json!({
"status": "alive",
"timestamp": chrono::Utc::now().to_rfc3339()
}))
}
/// Readiness probe — Kubernetes-compatible
pub async fn readiness() -> HttpResponse {
// TODO: Add database/redis ping checks here before returning "ready"
HttpResponse::Ok().json(serde_json::json!({
"status": "ready",
"timestamp": chrono::Utc::now().to_rfc3339()
}))
}
/// Health scope — registered directly as an HttpServiceFactory
pub fn health_scope() -> actix_web::Scope {
web::scope("/health")
.route("", web::get().to(health))
.route("/live", web::get().to(liveness))
.route("/ready", web::get().to(readiness))
}