use std::sync::Arc;
use axum::extract::State;
use axum::routing::get;
use axum::{Json, Router};
use serde::Serialize;
use utoipa::ToSchema;
use crate::api::AppState;
use crate::store::WorkflowStore;
#[derive(Serialize, ToSchema)]
pub struct VersionInfo {
pub version: &'static str,
pub build_profile: &'static str,
}
pub fn router<S: WorkflowStore + 'static>() -> Router<Arc<AppState<S>>> {
Router::new().route("/version", get(version))
}
#[utoipa::path(
get,
path = "/api/v1/version",
tag = "meta",
responses((status = 200, description = "Engine version info", body = VersionInfo)),
)]
pub async fn version<S: WorkflowStore>(
State(state): State<Arc<AppState<S>>>,
) -> Json<VersionInfo> {
let version = state
.binary_version
.unwrap_or(env!("CARGO_PKG_VERSION"));
Json(VersionInfo {
version,
build_profile: if cfg!(debug_assertions) {
"debug"
} else {
"release"
},
})
}