Expand description
Runtime network-profile switching API Runtime network-profile switching API.
Profiles like mobile_3g / lossy_network / extremely_poor come
from mockforge_core::network_profiles::NetworkProfileCatalog. They
were previously selectable only via --network-profile at startup,
which meant a hosted-mock operator couldn’t probe how their consumer
behaves on a slow network without redeploying.
This module exposes the catalog over HTTP and adds a middleware that applies the active profile’s latency on every request. Bandwidth and loss simulation are not yet wired through this path — latency is the 90% case for “what if my upstream gets slow” testing and is the cheapest to add without per-byte accounting.
§Endpoints
GET /__mockforge/api/network-profiles— list available profilesGET /__mockforge/api/network-profiles/active— current active profile (or 204 if none)POST /__mockforge/api/network-profiles/{name}/activate— switch to profilePOST /__mockforge/api/network-profiles/deactivate— clear
Structs§
- Network
Profile Runtime State - Cheap-to-clone shared state holding the catalog (immutable) plus the currently active profile (mutable).
Functions§
- network_
profile_ api_ router - Build the network-profile runtime API router. Mount under
/__mockforge/api/network-profiles. - network_
profile_ middleware - Middleware that applies the active profile’s latency before passing
to the next layer. Reads
NetworkProfileRuntimeState::active()per request — a swap takes effect on the very next call.