diff options
| author | soryu <soryu@soryu.co> | 2025-12-21 01:27:02 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2025-12-23 14:47:18 +0000 |
| commit | 3c696cfc9005e73be5ed46f8941dfc8f0aca7102 (patch) | |
| tree | 497bffd67001501a003739cfe0bb790502ffd50a /makima/src/server/mod.rs | |
| parent | 55cacf6e1a087c0fa6950a1ddeb09060f787e541 (diff) | |
| download | soryu-3c696cfc9005e73be5ed46f8941dfc8f0aca7102.tar.gz soryu-3c696cfc9005e73be5ed46f8941dfc8f0aca7102.zip | |
Create container image and move parakeet fork to vendor dir
Diffstat (limited to 'makima/src/server/mod.rs')
| -rw-r--r-- | makima/src/server/mod.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/makima/src/server/mod.rs b/makima/src/server/mod.rs index a6e0525..c509afa 100644 --- a/makima/src/server/mod.rs +++ b/makima/src/server/mod.rs @@ -6,9 +6,12 @@ pub mod openapi; pub mod state; use axum::{ + http::StatusCode, + response::IntoResponse, routing::get, - Router, + Json, Router, }; +use serde::Serialize; use tower_http::cors::{Any, CorsLayer}; use tower_http::trace::TraceLayer; use utoipa::OpenApi; @@ -18,6 +21,23 @@ use crate::server::handlers::listen; use crate::server::openapi::ApiDoc; use crate::server::state::SharedState; +#[derive(Serialize)] +struct HealthResponse { + status: &'static str, + version: &'static str, +} + +/// Health check endpoint for load balancers and orchestrators. +async fn health_check() -> impl IntoResponse { + ( + StatusCode::OK, + Json(HealthResponse { + status: "healthy", + version: env!("CARGO_PKG_VERSION"), + }), + ) +} + /// Create the axum Router with all routes configured. pub fn make_router(state: SharedState) -> Router { // API v1 routes @@ -29,6 +49,7 @@ pub fn make_router(state: SharedState) -> Router { .url("/api-docs/openapi.json", ApiDoc::openapi()); Router::new() + .route("/api/v1/healthcheck", get(health_check)) .nest("/api/v1", api_v1) .merge(swagger) .layer( |
