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 progress from a framework-independent Tower service to shared Redis counters. 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
Request-derived quotasCustom key extraction, LimitProvider, downstream contextmemory
Axum with nested policiesConnectInfo, global and route-scoped policiesaxum,memory
Trusted forwarded addressesDeployment-owned proxy trust policyaxum,memory
Axum with RedisShared Store, namespace, custom error responsesaxum,redis,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 example additionally requires 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.