Skip to main content

Crate boson_axum

Crate boson_axum 

Source
Expand description

HTTP admin API under /api/boson.

Requires a booted boson_runtime::Boson — see Getting started on the boson crate before mounting this router (§ 5).

§Entry points

§Handlers

RouteModulePurpose
/taskshandlers::tasksList and inspect registered tasks
/jobshandlers::jobsEnqueue, list, cancel jobs
/runshandlers::runsInspect run history
/tasks/{name}/confighandlers::configTask config read/update (no idempotency_mode)
/tasks/{name}/config/revisionshandlers::configStub — always returns []; revision history not implemented

See examples/axum_admin.rs in the boson crate for a runnable server.

§Example

use std::sync::Arc;

use axum::{extract::FromRef, Router};
use boson_axum::{boson_router, BosonState, NEST_PATH};
use boson_runtime::Boson;

#[derive(Clone)]
struct AppState {
    boson: BosonState,
}

impl FromRef<AppState> for BosonState {
    fn from_ref(state: &AppState) -> Self {
        state.boson.clone()
    }
}

fn mount(boson: Boson) -> Router<AppState> {
    Router::new()
        .nest(NEST_PATH, boson_router())
        .with_state(AppState {
            boson: BosonState::new(Arc::new(boson)),
        })
}

Structs§

BosonState
Extractable state holding a Boson runtime.

Constants§

NEST_PATH
Nest path for the Boson API router (/api/boson).

Functions§

boson_router
Create the Boson API router (mount at NEST_PATH).