api/routes/health.rs
1//! Health check routes.
2//!
3//! Provides a single `GET /health` endpoint that returns a simple success
4//! message, useful for uptime monitoring, load balancers, or deployment checks.
5
6use axum::{Router, routing::get, Json, response::IntoResponse};
7use util::state::AppState;
8use crate::response::ApiResponse;
9
10/// Builds the `/health` route group.
11///
12/// This includes a single `GET /health` endpoint that returns a basic success message.
13/// Useful for uptime checks, load balancers, or deployment health monitoring.
14///
15/// # Returns
16/// An Axum `Router` with the `GET /health` route configured.
17pub fn health_routes() -> Router<AppState> {
18 Router::new().route("/", get(health_check))
19}
20
21/// GET /health
22///
23/// Returns a simple success response to indicate the API is running.
24/// This is often used for uptime checks or health probes.
25///
26/// ### Response
27/// - `200 OK`
28///
29/// ```json
30/// {
31/// "success": true,
32/// "data": "OK",
33/// "message": "Health check passed"
34/// }
35/// ```
36async fn health_check() -> impl IntoResponse {
37 Json(ApiResponse::success("OK", "Health check passed"))
38}