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::ctx::WorkflowCtx;
26use crate::store::WorkflowStore;
27
28pub fn router<S: WorkflowStore + 'static>() -> Router<Arc<WorkflowCtx<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/engine/workflow/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/engine/workflow/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<WorkflowCtx<S>>>,
62) -> Json<VersionInfo> {
63 let version = state.binary_version.unwrap_or(env!("CARGO_PKG_VERSION"));
64 Json(VersionInfo {
65 version,
66 build_profile: if cfg!(debug_assertions) {
67 "debug"
68 } else {
69 "release"
70 },
71 })
72}