Skip to content

Commit b0e41f3

Browse files
authored
feat(healthz): expose a /healthz for CocoIndex server (#1270)
1 parent 72493e7 commit b0e41f3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/server.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::prelude::*;
22

33
use crate::{lib_context::LibContext, service};
4+
use axum::response::Json;
45
use axum::{Router, routing};
56
use tower::ServiceBuilder;
67
use tower_http::{
@@ -37,6 +38,7 @@ pub async fn init_server(
3738
.allow_headers([axum::http::header::CONTENT_TYPE]);
3839
}
3940
let app = Router::new()
41+
.route("/healthz", routing::get(healthz))
4042
.route(
4143
"/cocoindex",
4244
routing::get(|| async { "CocoIndex is running!" }),
@@ -92,3 +94,10 @@ pub async fn init_server(
9294
let serve_fut = async { axum::serve(listener, app).await.unwrap() };
9395
Ok(serve_fut.boxed())
9496
}
97+
98+
async fn healthz() -> Json<serde_json::Value> {
99+
Json(serde_json::json!({
100+
"status": "ok",
101+
"version": env!("CARGO_PKG_VERSION"),
102+
}))
103+
}

0 commit comments

Comments
 (0)