[rust-axum] Add support for multiple response types and streaming responses #22095
+546
−128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change enables two related features in the rust-axum server generator
The core of the feature is to iterate over the content types rather than taking just the first, then build up a new list in the vendor extensions that includes the appropriate information. I took the approach of still keeping the templates simple and tried to compute types in the Java code as much as possible - we could of course go the other way and expand the type within the template, but it got pretty gnarly.
@linxGnu - I adopted a bit of a hybrid approach to the typing we discussed since this isn't just a return type change, it changes the enums. I went ahead and used a
(along with appropriate Sends/Syncs/'static annotations). This allowed me to shove it in an enum, and it appears to play nice with other methods that return an
impl Stream
orimpl TryStream
, both of which can be coerced into the pin-box using the.boxed()
method fromStreamExt
.Finally, the templates are updated to support the new code gen. I have validated this two ways:
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)"fixes #123"
present in the PR description)fixes [REQ] [rust-axum] support text/event-stream #21967
@frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05) @jacob-pro (2022/10) @dsteeley (2025/07)