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

add IntoResponse impl on custom Json extractor example #2191

Merged

Conversation

lennart
Copy link
Contributor

@lennart lennart commented Aug 22, 2023

Motivation

The current custom-extractor-error/derive_from_requst example does not allow the wrapped Json extractor to be used as a response.

Solution

Adding an impl for IntoResponse for the custom extractor provides the same ergonomics as the original axum::Json.

NOTE: the example now also echoes back the parsed json request body (which it wasn't before and therefore the code did compile without the impl)

edit(jplatte): Closes #2186.

also let the endpoint echo back the parsed json request body

closes tokio-rs#2186
Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Thanks!

@jplatte jplatte enabled auto-merge (squash) August 22, 2023 08:40
@jplatte
Copy link
Member

jplatte commented Aug 22, 2023

Oh, new clippy lints and an ICE from cargo-public-api-crates 😅

@lennart to be clear, none of this is related to your PR. We'll fix it separately and merge your PR afterwards.

@davidpdrsn
Copy link
Member

CI should pass if you merge the latest main.

@jplatte
Copy link
Member

jplatte commented Aug 22, 2023

No it won't, my PR was incomplete. It only fixed clippy, not cargo-public-api-crates. See also what I sent you on Discord 😅

@davidpdrsn
Copy link
Member

Oh okay. I’m afk right now but will check later.

@jplatte jplatte merged commit 368c3ee into tokio-rs:main Sep 11, 2023
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.

Cannot use wrapped JSON Extractor for responses based on derive_from_request example
3 participants