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

Emphasize that Request extractor goes last #2834

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

bittrance
Copy link
Contributor

Motivation

The error message you get when passing an invalid fn or closure to from_fn is rather far removed from the actual error. The itemized list in https://docs.rs/axum/latest/axum/middleware/fn.from_fn.html makes no mention of the limitation that Request must be the last extractor. This is only mentioned in passing in the auth middleware example a way down the page.

Solution

Given that putting extractors in the wrong order risks causing a lot of confusion, this PR promotes the ordering requirement to the top of from_fn docs so that it is easier to note.

Copy link
Contributor

@mladedav mladedav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving the docs!

axum/src/middleware/from_fn.rs Outdated Show resolved Hide resolved
axum/src/middleware/from_fn.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@mladedav mladedav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@jplatte jplatte merged commit 205371a into tokio-rs:main Jul 19, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants