feat(server): add /api/version endpoint exposing git hash

This commit is contained in:
Riz Ashraf committed 2026-09-12 09:00:38 +01:00
1 parent 248799ca5d
commit 44df610998
2 files changed
+17

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
use std::process::Command;
fn main() {
if let Ok(output) = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output() {
if let Ok(hash) = String::from_utf8(output.stdout) {
println!("cargo:rustc-env=GIT_HASH={}", hash.trim());
}
}
println!("cargo:rerun-if-changed=../.git/HEAD");
println!("cargo:rerun-if-changed=../.git/index");
}
+6
View File
@@ -243,6 +243,12 @@ fn run_server(state: Arc<MemoryState>) -> Result<(), Box<dyn std::error::Error>>
}); });
let app = Router::new() let app = Router::new()
.route("/api/version", get(|| async move {
axum::Json(serde_json::json!({
"version": env!("CARGO_PKG_VERSION"),
"git_hash": option_env!("GIT_HASH").unwrap_or("unknown")
}))
}))
.route("/sse", get(sse_handler)) .route("/sse", get(sse_handler))
.route("/messages", post(message_handler)) .route("/messages", post(message_handler))
.route("/health", get(health_handler)) .route("/health", get(health_handler))