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
boson_router— mount underNEST_PATH(/api/boson)BosonState/BosonStateBuilder— shared Axum state, optionalAdminAuthAdminAuth,StaticTokenAdminAuth,REQUIRE_ADMIN_AUTH_ENV— host auth seamMAX_LIST_LIMIT— hard cap for list querylimit
§Owns / does not own
Owns: route table, DTO shaping (no actor_json / params_json on wire), list caps,
default non-System HTTP enqueue actor, optional admin auth middleware.
Does not own: Soliton HMAC, mTLS, session cookies — hosts implement AdminAuth.
§Handlers
| Route | Module | Purpose |
|---|---|---|
/tasks | handlers::tasks | List and inspect registered tasks |
/jobs | handlers::jobs | Enqueue, list, cancel jobs |
/runs | handlers::runs | Inspect run history |
/tasks/{name}/config | handlers::config | Task config read/update (no idempotency_mode) |
/tasks/{name}/config/revisions | handlers::config | Stub — always returns []; revision history not implemented |
See examples/axum_admin.rs in the boson crate for a runnable server.
§Example — completed setup with admin auth
use std::sync::Arc;
use axum::{extract::FromRef, Router};
use boson_axum::{
boson_router, BosonAxumError, BosonState, StaticTokenAdminAuth, 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) -> Result<Router<AppState>, BosonAxumError> {
let state = BosonState::builder(Arc::new(boson))
.admin_auth(Arc::new(StaticTokenAdminAuth::new("lab-token")))
.require_admin_auth(true)
.build()?;
Ok(Router::new()
.nest(NEST_PATH, boson_router())
.with_state(AppState { boson: state }))
}Structs§
- Admin
Auth Error - Rejection from
AdminAuth::authorize. - Allow
AllAdmin Auth - Shared always-allow verifier for local tests (not for production).
- Boson
State - Extractable state holding a
Bosonruntime and optional admin auth. - Boson
State Builder - Build
BosonStatewith admin auth and actor overrides. - Require
Admin - Extractor that enforces
BosonState::admin_auth/ require-flag before the handler runs. - Static
Token Admin Auth - Header-based verifier: require
x-boson-admin-tokenequal to the configured secret.
Enums§
- Boson
Axum Error - Errors from
BosonStateBuilder::build.
Constants§
- DEFAULT_
LIST_ LIMIT - Default
limitwhen the query omits it. - MAX_
LIST_ LIMIT - Hard maximum rows returned by list endpoints.
- MAX_
RETRY_ ATTEMPTS - Maximum
RetryPolicy::max_attemptsaccepted via HTTP config upsert. - MAX_
RETRY_ DELAY_ MS - Maximum retry delay via HTTP (milliseconds).
- MIN_
RETRY_ DELAY_ MS - Minimum
base_delay_ms/max_delay_msvia HTTP (milliseconds). - NEST_
PATH - Nest path for the Boson API router (
/api/boson). - REQUIRE_
ADMIN_ AUTH_ ENV - Environment variable: when
1/true/yes, admin routes require a configuredAdminAuth.
Traits§
- Admin
Auth - Host-supplied verifier for Boson admin HTTP.
Functions§
- boson_
router - Create the Boson API router (mount at
NEST_PATH). - clamp_
list_ limit - Clamp an optional list limit into
[1, MAX_LIST_LIMIT](defaultDEFAULT_LIST_LIMIT). - clamp_
retry_ policy - Validate and clamp retry policy fields for HTTP upsert.
- parse_
require_ admin_ auth - Parse a require-admin-auth flag string (
1/true/yes, case-insensitive). - require_
admin_ auth_ from_ env - Read
REQUIRE_ADMIN_AUTH_ENV:1,true, oryes(case-insensitive) ⇒ required.
Type Aliases§
- Http
Enqueue Actor Provider - Callback that supplies
actor_jsonfor HTTP enqueue (overrides the default service marker).