-
Notifications
You must be signed in to change notification settings - Fork 1k
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 multipart/form-data response builders to axum-extra #2654
Conversation
I may need some help fixing those CI errors, I am unsure how to address them |
Ok, I managed to fix all of those CI errors, thank you for your patience |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, for the PR I think the functionality looks good. I have not personally worked with multipart on this level so I don't know much of the technical details but I did comment on some of the other stuff.
I have commit ready to fix some of those minor issues, I just need to figure out how to handle mime type stuff from a public api level |
I don't know how to do that, any advice would be appreciated |
I gave up and just made any mime parsing happen internally, and the associated functions return an error. I ran as much CI as I could with |
Is there anything more this PR needs? |
No, it's just waiting on my review. I've started looking at it now. |
Those changes have been applied, thank you for your feedback :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have the energy to do another review, but I think this has seen enough attention that we should just merge it by now.
There's just some doc comment rewrapping I wanna apply before merging (can likely commit it myself).
Do you want this to be released in another axum-extr 0.9.x patch release? It's not a huge effort but if you don't care, I'll let it sit until I have another reason to make a patch release, or it's time for 0.10.0. |
Feel free to let it sit, this is fairly low priority for me. Thanks :) |
Closes #2624 (mine)
This pull request provides builders that enable
multipart/form-data
forms to be returned from handlers.Motivation
multipart/form-data
forms provide a way to include multiple types of data in a single response as key value pairs. You could include an image and a JSON, or any other combination of data.As an example, this could be used for a pastebin, so that a single request to an axum backend could return metadata about a paste in a json, and the paste itself. The paste wouldn't need to conform to UTF-8, and could be sent separately from the json.
Solution
I added a
MultipartForm
struct that implementsIntoResponse
, and implementers can add parts to that form by definingPart
s. I did not implementIntoResponse
on theMultipart
extractor, as advised in the original issue.One dependency was added if the
multipart
feature is enabled.fastrand
is used to generate boundaries, mirroring Reqwest's implementation.Thank you for your time :)