Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Examples

The examples cover a framework-independent Tower service, fixed-window counters, and GCRA policies. Every page below embeds the complete source file used by the repository, so the documentation and the compiled example cannot drift independently.

ExampleWhat it demonstratesRequired features
Tower with MemoryStoreMinimal Tower Layer compositionmemory
Axum with nested policiesConnectInfo, global and route-scoped policiesaxum,memory
Trusted proxy client IPPeer-policy-gated client-IP extraction behind a trusted proxyaxum,memory
Axum with RedisShared fixed-window state, namespace, custom error responsesaxum,redis,runtime-tokio
Axum with Memory GCRAProcess-local burst quota and application-owned periodic cleanupaxum,memory-gcra
Axum with Redis GCRAShared burst quota through ordinary Redisaxum,redis-gcra,runtime-tokio

Run an example from the repository root with the command shown on its page. The Axum examples start an HTTP server and keep running until interrupted. The Redis examples additionally require REDIS_URL to reference a reachable Redis server.

These programs are intentionally small. They demonstrate the limiter boundary, not production authentication, proxy configuration, connection supervision, observability, or graceful shutdown. Review the Production guide before adapting them to a deployed service.