assay_workflow/api/
meta.rs1use std::sync::Arc;
10
11use axum::extract::State;
12use axum::routing::get;
13use axum::{Json, Router};
14use serde::Serialize;
15use utoipa::ToSchema;
16
17use crate::api::AppState;
18use crate::store::WorkflowStore;
19
20#[derive(Serialize, ToSchema)]
21pub struct VersionInfo {
22 pub version: &'static str,
25 pub build_profile: &'static str,
27}
28
29pub fn router<S: WorkflowStore + 'static>() -> Router<Arc<AppState<S>>> {
30 Router::new().route("/version", get(version))
31}
32
33#[utoipa::path(
34 get,
35 path = "/api/v1/version",
36 tag = "meta",
37 responses((status = 200, description = "Engine version info", body = VersionInfo)),
38)]
39pub async fn version<S: WorkflowStore>(
40 State(state): State<Arc<AppState<S>>>,
41) -> Json<VersionInfo> {
42 let version = state
46 .binary_version
47 .unwrap_or(env!("CARGO_PKG_VERSION"));
48 Json(VersionInfo {
49 version,
50 build_profile: if cfg!(debug_assertions) {
51 "debug"
52 } else {
53 "release"
54 },
55 })
56}