New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how state works with merge
and nest
#1313
Comments
Yeah I noticed this when using AxumFlash and passing the config as the State. I had to change my Routing functions to take in the State to set them individually.
which results in
|
#1368 is making things more flexible. When that is in I'll write some docs for it. |
I think we're in a good place in terms for docs. We can expand things when people ask questions but for now I'll close this. |
I think the docs could still be improved for this. I looked in these three places to try to figure this out (none of which explain it) before I found the API docs for
I think it's worth explaining directly in the documentation for |
Good idea. Do you wanna make a pr? |
I was going to improve the discoverability of docs for how state works with `Router::merge` and `Router::nest` based on my comment in tokio-rs#1313, but tokio-rs#1532 removes `Router::inherit_state` so I discovered that the change I originally suggested isn't necessary anymore. I decided to make a few other minor documentation fixes while I was reading, however: * Corrected the docs for `Router::nest` to say that it nests another `Router` rather than a `Service`. There is a separate function (`Router::nest_service`) for the latter. * Changed one of the headings in nest.md to use more idiomatic English. * Changed awkward phrasing under the "Sharing state with handlers" heading of the root documentation page. * Removed a trailing period from one of three list items for consistency.
Per my comment in tokio-rs#1313, this improves discoverability of how `State` works with nested/merged `Router`s. I made a few other minor documentation fixes while I was reading: * Corrected the docs for `Router::nest` to say that it nests another `Router` rather than a `Service`. There is a separate function (`Router::nest_service`) for the latter. * Changed one of the headings in nest.md to use more idiomatic English. * Changed awkward phrasing under the "Sharing state with handlers" heading of the root documentation page. * Removed a trailing period from one of three list items for consistency.
Gotten a few questions about how states work with
merge
andnest
. Things like whether the state needs to be passed to each router and whether the state of the inner routers is dropped. This is something we should document.The text was updated successfully, but these errors were encountered: