Expand description
Runtime route-scoped chaos rules API Runtime route-scoped chaos API.
Static route_configs from the YAML config get baked into per-route
handlers at startup. This module provides the runtime counterpart:
a shared, mutable rule set that operators can update via HTTP without
restarting the deployment. A middleware layer consults the live state
on every request.
§Why additive (rather than replacing the static path)
Each static route is registered as its own Axum handler that captures
a clone of the initial injector — refactoring all of them to read a
shared RwLock would touch a lot of unrelated code. Instead this
middleware runs in front of the static handlers: if a runtime rule
injects a fault, we short-circuit; otherwise we fall through. Routes
that are configured both statically and at runtime have the runtime
rule win — that’s the surprise-minimising default for an operator
who’s just turned on a fault via API.
§Endpoints
GET /__mockforge/api/route-chaos— list rulesPUT /__mockforge/api/route-chaos— replace all rulesPOST /__mockforge/api/route-chaos/route— add or upsert one ruleDELETE /__mockforge/api/route-chaos/route— remove one rule by method+path
Structs§
- Runtime
Route Chaos State - Shared, mutable set of route-chaos rules. Cheap to clone (Arc).
Functions§
- route_
chaos_ api_ router - Build the runtime route-chaos API router. Mount under
/__mockforge/api/route-chaos. - runtime_
route_ chaos_ middleware - Middleware that runs before the static route handlers. If a runtime rule injects a fault, return it; otherwise fall through.