Skip to content

middleware::from_fn fails if fn calls async fn with &Request argument #2571

Answered by davidpdrsn
dfaust asked this question in Q&A
Discussion options

You must be logged in to vote

Passing &Request creates a future that is !Send (because Request<axum::body::Body> is !Sync, which Request is a typealias for).

So you either have to pass the request by value (ownership) or use request.into_parts() and pass things separately.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@dfaust
Comment options

@davidpdrsn
Comment options

Answer selected by dfaust
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2570 on February 06, 2024 20:53.