Examples
The Volter repository includes several runnable workspace member packages in
the examples/ directory. Run any of them from the workspace root with
cargo run -p <name>.
Basic Examples
Hello World
cargo run -p hello-world
A minimal server with a single route returning “Hello, World!”.
Path Parameters
cargo run -p path-params
Path parameters with Path<T> for single and multi-parameter routes.
Query Parameters
cargo run -p query-params
URL query parameter parsing with Query<T>.
JSON
cargo run -p json-example
JSON request body deserialization and JSON response serialization.
Merge
cargo run -p merge
Combining independent routers with Router::merge().
Nesting
cargo run -p nesting
Mounting routers under a path prefix with Router::nest().
Extensions
cargo run -p extensions-example
Request extensions set by middleware and consumed by handlers.
Multiple Extractors
cargo run -p multi-extractors-example
Handlers using two extractors (e.g. State + Query).
Derive Macros
Derive Extractors
cargo run -p derive-extractors
Using #[derive(FromRequestParts)] and #[derive(FromRequest)] on your types.
Route Attribute Macros
Route Macros
cargo run -p route-macros
Using #[get], #[post], #[put], #[patch], #[delete], #[head], and #[options] with Router::route_attr(). Demonstrates a full REST-style API.
WebSocket
cargo run -p websocket
A basic WebSocket echo server.
Middleware
Catch Panic
cargo run -p catch-panic-example
Panic recovery with CatchPanicLayer.
Timeout
cargo run -p timeout-example
Request timeouts with TimeoutLayer.
Tracing
cargo run -p tracing-example
Request logging with TraceLayer.
CORS
cargo run -p cors-example
Cross-Origin Resource Sharing with CorsLayer.
Compression
cargo run -p compression-example
Response compression with CompressionLayer.
Body Limit
cargo run -p body-limit-example
Request body size limiting with RequestBodyLimitLayer.
Concurrency Limit
cargo run -p concurrency-limit-example
Limiting concurrent requests with ConcurrencyLimitLayer.
Rate Limit
cargo run -p rate-limit-example
Fixed-window rate limiting with RateLimitLayer.
Request ID
cargo run -p request-id-example
Unique per-request IDs with RequestIdLayer.
Custom Middleware
cargo run -p middleware-example
Implementing tower::Layer and tower::Service for custom middleware.
Running Examples
All examples start a server on http://127.0.0.1:3000 by default. Check the
example source for the exact port and available routes.