Skip to main content

Module middleware

Module middleware 

Source

Re-exports§

pub use store::CircuitAction;
pub use store::CircuitBreakerStore;
pub use store::RateLimitStore;
pub use store::SlidingWindowStore;

Modules§

store

Structs§

BandwidthThrottle
Tower layer that throttles response body throughput to simulate slow connections.
BlockList
Tower layer that blocks requests matching a predicate and returns a configurable error response (default: 403 Forbidden).
CircuitBreaker
Tower layer that implements the circuit breaker pattern.
Conditional
Tower layer that conditionally applies middlewares based on per-request predicates.
ContentDecoder
Tower layer that transparently decompresses response bodies.
FaultInjector
Tower layer that randomly injects faults into proxied requests.
InMemoryCircuitBreakerStore
In-memory circuit breaker store backed by a HashMap.
InMemoryRateLimitStore
In-memory token-bucket store backed by a HashMap.
InMemorySlidingWindowStore
In-memory sliding-window store backed by a HashMap.
LatencyInjector
Tower layer that adds artificial latency before forwarding requests.
ModifyHeaders
Tower layer that adds, replaces, or removes HTTP headers on requests and/or responses.
Next
Handle to the next service in the middleware chain.
RateLimiter
Tower layer that rate-limits requests using a token bucket algorithm.
Retry
Tower layer that retries requests when upstream returns specific status codes.
Router
Tower layer that routes requests to different upstreams based on predicates.
SetResponse
Tower layer that ignores the upstream and returns a fixed response.
SlidingWindow
Sliding window log algorithm: stores a VecDeque<Instant> of request timestamps per key. On each request, entries older than window are drained. If the window has capacity (len < count), the request proceeds immediately. Otherwise, the request sleeps until the oldest entry expires and a slot opens.
TrafficLogger
Tower layer that logs HTTP request/response traffic.
Upstream
One or more backend URLs with a load-balancing strategy.
UrlRewrite
Tower layer that rewrites request URI paths before forwarding upstream.

Enums§

LoadBalanceStrategy
Load-balancing strategy for upstreams with multiple backends.

Traits§

ConditionalLayer
Extension trait that lets any tower layer add a condition directly.

Functions§

from_fn
Create a tower Layer from an async function.