kova-api 0.2.0

Kova HTTP API: health probe and embedded GUI serving
Documentation
//! kova-api: HTTP API.
//!
//! `GET /health` — liveness probe.
//! `GET /` — embedded GUI (from `kova-gui`).
//! The SSE pipeline event stream lands with the engine.

use axum::{routing::get, Json, Router};
use serde_json::json;

/// Build the API router.
pub fn router() -> Router {
    Router::new()
        .route("/health", get(health))
        .route("/", get(index))
}

async fn health() -> Json<serde_json::Value> {
    Json(json!({
        "status": "ok",
        "service": "kova",
        "version": env!("CARGO_PKG_VERSION"),
    }))
}

async fn index() -> String {
    kova_gui::index_html()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn router_builds() {
        let _ = router();
    }

    #[tokio::test]
    async fn health_payload_is_ok() {
        let v = health().await.0;
        assert_eq!(v["status"], "ok");
        assert_eq!(v["service"], "kova");
    }

    #[tokio::test]
    async fn index_serves_embedded_gui() {
        assert!(index().await.contains("Kova"));
    }
}