Clarify middleware::from_fn argument requirements (#2834)

This commit is contained in:
Bittrance 2024-07-19 10:29:23 +02:00 committed by GitHub
parent 74eac39e06
commit 205371a6b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,9 +19,10 @@ use tower_service::Service;
/// `from_fn` requires the function given to
///
/// 1. Be an `async fn`.
/// 2. Take one or more [extractors] as the first arguments.
/// 3. Take [`Next`](Next) as the final argument.
/// 4. Return something that implements [`IntoResponse`].
/// 2. Take zero or more [`FromRequestParts`] extractors.
/// 3. Take exactly one [`FromRequest`] extractor as the second to last argument.
/// 4. Take [`Next`](Next) as the last argument.
/// 5. Return something that implements [`IntoResponse`].
///
/// Note that this function doesn't support extracting [`State`]. For that, use [`from_fn_with_state`].
///