Skip to content

Commit

Permalink
Emphasize that Request extractor goes last.
Browse files Browse the repository at this point in the history
  • Loading branch information
bittrance committed Jul 16, 2024
1 parent 74eac39 commit eb8c243
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions axum/src/middleware/from_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use tower_service::Service;
/// 3. Take [`Next`](Next) as the final argument.
/// 4. Return something that implements [`IntoResponse`].
///
/// The last extractor (i.e. the second last argument) must be [`Request`] or some type implementing [`FromRequest`].
///
/// Note that this function doesn't support extracting [`State`]. For that, use [`from_fn_with_state`].
///
/// # Example
Expand Down Expand Up @@ -71,9 +73,7 @@ use tower_service::Service;
/// async fn auth(
/// // run the `HeaderMap` extractor
/// headers: HeaderMap,
/// // you can also add more extractors here but the last
/// // extractor must implement `FromRequest` which
/// // `Request` does
/// // a `FromRequest` implementation must be the last extractor
/// request: Request,
/// next: Next,
/// ) -> Result<Response, StatusCode> {
Expand Down

0 comments on commit eb8c243

Please sign in to comment.