From 205371a6b52b3be63cb75b1f3b1ae275340d382c Mon Sep 17 00:00:00 2001 From: Bittrance Date: Fri, 19 Jul 2024 10:29:23 +0200 Subject: [PATCH] Clarify middleware::from_fn argument requirements (#2834) --- axum/src/middleware/from_fn.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/axum/src/middleware/from_fn.rs b/axum/src/middleware/from_fn.rs index e4c44c74..3ed7a959 100644 --- a/axum/src/middleware/from_fn.rs +++ b/axum/src/middleware/from_fn.rs @@ -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`]. ///