use axum::{routing::get, Json, Router};
use serde_json::json;
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"));
}
}