kegani-cli 0.1.4

CLI tool for Kegani framework
Documentation
//! Health check routes
//!
//! Mounted at /health (or /api/health when used under a scope).
//! Note: Swagger UI and ReDoc are automatically served at
//! /api-docs/swagger-ui and /api-docs/redoc by Kegani's App builder.

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))
}