Skip to content
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

Improve State and Router docs #1543

Merged
merged 4 commits into from Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions axum/src/docs/routing/nest.md
@@ -1,4 +1,4 @@
Nest a [`Service`] at some path.
Nest a [`Router`] at some path.

This allows you to break your application into smaller pieces and compose
them together.
Expand Down Expand Up @@ -64,7 +64,7 @@ let app = Router::new().nest("/:version/api", users_api);
# };
```

# Differences to wildcard routes
# Differences from wildcard routes

Nested routes are similar to wildcard routes. The difference is that
wildcard routes still see the whole URI whereas nested routes will have
Expand Down
10 changes: 9 additions & 1 deletion axum/src/extract/state.rs
Expand Up @@ -8,7 +8,7 @@ use std::{

/// Extractor for state.
///
/// See ["Accessing state in middleware"][state-from-middleware] for how to
/// See ["Accessing state in middleware"][state-from-middleware] for how to
/// access state in middleware.
///
/// [state-from-middleware]: crate::middleware#accessing-state-in-middleware
Expand Down Expand Up @@ -46,6 +46,14 @@ use std::{
/// # let _: axum::routing::RouterService = app;
/// ```
///
/// [`Router`]s that are combined with [`Router::nest`] or [`Router::merge`]
/// generally require the same type of state. See [`Router::nest`] for how to
/// combine routers with different types of state.
///
/// [`Router`]: crate::Router
/// [`Router::nest`]: crate::Router::nest
/// [`Router::merge`]: crate::Router::merge
///
/// # With `MethodRouter`
///
/// ```
Expand Down
7 changes: 4 additions & 3 deletions axum/src/lib.rs
Expand Up @@ -164,11 +164,12 @@
//!
//! # Sharing state with handlers
//!
//! It is common to share some state between handlers for example to share a
//! pool of database connections or clients to other services.
//! It is common to share some state between handlers. For example, a
//! pool of database connections or clients to other services may need to
//! be shared.
//!
//! The three most common ways of doing that are:
//! - Using the [`State`] extractor.
//! - Using the [`State`] extractor
//! - Using request extensions
//! - Using closure captures
//!
Expand Down