Skip to main content

Module route_chaos_runtime

Module route_chaos_runtime 

Source
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 rules
  • PUT /__mockforge/api/route-chaos — replace all rules
  • POST /__mockforge/api/route-chaos/route — add or upsert one rule
  • DELETE /__mockforge/api/route-chaos/route — remove one rule by method+path

Structs§

RuntimeRouteChaosState
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.