use axum::Router;
use axum::http::StatusCode;
use axum::response::IntoResponse;
use axum::routing::get;
pub fn routes() -> Router {
Router::new().route("/health", get(health_handler))
}
async fn health_handler() -> impl IntoResponse {
(
StatusCode::OK,
[(axum::http::header::CONTENT_TYPE, "application/json")],
r#"{"status":"ok"}"#,
)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::App;
use crate::test::TestClient;
#[tokio::test]
async fn health_check_returns_200_with_ok_status() {
let app = App::new().without_defaults().routes(routes()).build();
let client = TestClient::new(app);
let resp = client.get("/health").send().await;
resp.assert_status(200);
let body: serde_json::Value = resp.json();
assert_eq!(body["status"], "ok");
}
}