Skip to content

axum-extra: implement FromRequest for Either* #3323

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

mladedav
Copy link
Collaborator

Motivation

Either can currently be used only for FromRequestParts extractor. We might want to support extraction of different kinds of bodies. Example of a user wanting something like this is #3315

Solution

Have Either buffer the whole body into Bytes and then try the extractors in turn.

@jplatte
Copy link
Member

jplatte commented Apr 26, 2025

This seems like a little bit of a footgun potentially. Using Either<Json<T>, Form<T>> is going to buffer the request body regardless of the content type.

I'm also wondering whether / how to support Either<impl FromRequest, impl FromRequestParts> or Either<impl FromRequestParts, impl FromRequest>. I'm pretty sure those don't work with this PR as-is.

Any comments / thoughts?

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.

2 participants