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

[doc] Added notes about extractor precedence #1324

Merged
merged 6 commits into from
Aug 26, 2022

Conversation

chrisglass
Copy link
Contributor

Added a note in the structs docs pointing to the relevant part of the documentation regarding extractor precedence.

Motivation

During discussion of a slightly unrelated problem (#1321), it was discovered that my example was ordering the extractors wrong, causing a compile-time problem.

Solution

This PR should hopefully make the solution for the above problem (reordering extractors) a little bit more discoverable.

Both JSON and Form extractors consume the Body when they run, so they
need to be last in the order of extractors.
Added a note in the structs docs themselves pointing to the relevant
part of the documentation.
Copy link
Member

@davidpdrsn davidpdrsn left a comment

Choose a reason for hiding this comment

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

I think this is worth having!

I think we should add it to the other types we have that only implement `FromRequest:

  • BodyStream
  • RawBody
  • Multipart
  • ContentLengthLimit, note this one is conditional, only if what its wrapping implements FromRequest. The docs should mention that.

axum/src/form.rs Outdated Show resolved Hide resolved
axum/src/json.rs Outdated Show resolved Hide resolved
@davidpdrsn davidpdrsn added T-docs Topic: documentation A-axum labels Aug 25, 2022
@davidpdrsn davidpdrsn added this to the 0.6 milestone Aug 25, 2022
- Added documentation snippet to  BodyStream, RawBody, Multipart
- Added documentation about the inner type of ContentLengthLimit
- Fixed link type in State
@chrisglass
Copy link
Contributor Author

All comments are addressed (I think!)

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
@chrisglass
Copy link
Contributor Author

Well, CI failed :) will fix that later today.

I need to check my editor config...
axum/src/extract/content_length_limit.rs Outdated Show resolved Hide resolved
axum/src/extract/content_length_limit.rs Outdated Show resolved Hide resolved
axum/src/extract/multipart.rs Outdated Show resolved Hide resolved
chrisglass and others added 2 commits August 26, 2022 09:41
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
Copy link
Member

@davidpdrsn davidpdrsn left a comment

Choose a reason for hiding this comment

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

Thanks!

@davidpdrsn davidpdrsn merged commit b2ed55b into tokio-rs:main Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-axum T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants