Skip to main content

assay_workflow/api/
mod.rs

1pub mod activities;
2pub mod events;
3pub mod namespaces;
4pub mod openapi;
5pub mod public;
6pub mod queues;
7pub mod schedules;
8pub mod tasks;
9pub mod workers;
10pub mod workflow_tasks;
11pub mod workflows;
12
13use std::sync::Arc;
14
15use axum::Router;
16
17use crate::ctx::WorkflowCtx;
18use crate::store::WorkflowStore;
19
20/// Build the workflow HTTP API router.
21///
22/// Three tiers, all under `/api/v1/engine/workflow/*`:
23///
24/// 1. **Authenticated** — workflows, schedules, namespaces, activities,
25///    tasks, workers, queues, events. Authentication + authorization
26///    happens at the engine layer (via [`assay_auth::gate`] in
27///    `assay_engine::server`); the workflow router itself carries no
28///    gate. (The `workflow.api_keys` surface was retired in plan-15
29///    slice 3 — auth tokens come from the auth module now.)
30/// 2. **Public** — health, version. Always unauthenticated so
31///    Kubernetes probes, load balancers, and third-party monitors can
32///    reach them without a bearer token.
33/// 3. **OpenAPI** — `openapi.json` + `docs` HTML. Always public.
34///
35/// The standalone `serve*` entry points were removed in plan-15
36/// slice 2 — workflow now only runs inside `assay-engine`, which owns
37/// the listener, the auth gate, and the surrounding state.
38pub fn router<S: WorkflowStore>(state: Arc<WorkflowCtx<S>>) -> Router {
39    let authed_api = Router::new()
40        .nest("/api/v1/engine/workflow", api_v1_router::<S>())
41        .nest("/api/v1/engine/workflow", events::router::<S>());
42
43    let public_api = Router::new().nest("/api/v1/engine/workflow", public::router::<S>());
44
45    let app = authed_api.merge(public_api).merge(openapi::router::<S>());
46
47    app.with_state(state)
48}
49
50fn api_v1_router<S: WorkflowStore>() -> Router<Arc<WorkflowCtx<S>>> {
51    Router::new()
52        .merge(workflows::router::<S>())
53        .merge(activities::router::<S>())
54        .merge(workflow_tasks::router::<S>())
55        .merge(tasks::router::<S>())
56        .merge(schedules::router::<S>())
57        .merge(workers::router::<S>())
58        .merge(namespaces::router::<S>())
59        .merge(queues::router::<S>())
60}