Skip to content

Glossary: Rust in Practice

Router and State

Also written: Router, State, with_state

An Axum `Router` maps URLs to handlers, and `.with_state(pool)` shares a value, such as the database pool, with every handler that takes `State(pool): State<SqlitePool>`. Axum clones the state for each request.

Where the book teaches it

Related terms

handlerconnection poollayer