assay_workflow/api/
public.rs1use std::sync::Arc;
18
19use axum::extract::State;
20use axum::routing::get;
21use axum::{Json, Router};
22use serde::Serialize;
23use utoipa::ToSchema;
24
25use crate::api::AppState;
26use crate::store::WorkflowStore;
27
28pub fn router<S: WorkflowStore + 'static>() -> Router<Arc<AppState<S>>> {
29 Router::new()
30 .route("/health", get(health_check))
31 .route("/version", get(version))
32}
33
34#[utoipa::path(
35 get, path = "/api/v1/health",
36 tag = "public",
37 responses((status = 200, description = "Engine health — always unauthenticated")),
38)]
39pub async fn health_check() -> Json<serde_json::Value> {
40 Json(serde_json::json!({
41 "status": "ok",
42 "service": "assay-workflow",
43 }))
44}
45
46#[derive(Serialize, ToSchema)]
47pub struct VersionInfo {
48 pub version: &'static str,
51 pub build_profile: &'static str,
53}
54
55#[utoipa::path(
56 get, path = "/api/v1/version",
57 tag = "public",
58 responses((status = 200, description = "Engine version info", body = VersionInfo)),
59)]
60pub async fn version<S: WorkflowStore>(
61 State(state): State<Arc<AppState<S>>>,
62) -> Json<VersionInfo> {
63 let version = state
64 .binary_version
65 .unwrap_or(env!("CARGO_PKG_VERSION"));
66 Json(VersionInfo {
67 version,
68 build_profile: if cfg!(debug_assertions) {
69 "debug"
70 } else {
71 "release"
72 },
73 })
74}