-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Introduce a way to set headers and status code for streaming response #33197
Conversation
@cescoffier WDYT? |
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.
Just made a small comment.
...c/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/streams/StreamResource.java
Outdated
Show resolved
Hide resolved
🙈 The PR is closed and the preview is expired. |
This comment has been minimized.
This comment has been minimized.
@cescoffier I pushed a second commit which makes this feature even more usable, you might want to have a look as I needed to introduce a custom Multi (the implementation was copied pretty much verbatim from existing Mutiny code) |
Failing Jobs - Building 0e313b6
Full information is available in the Build summary check run. Failures⚙️ JVM Tests - JDK 17 Windows #- Failing: integration-tests/mongodb-panache
📦 integration-tests/mongodb-panache✖
|
Works for my use case as well. Thanks. I'm just wondering if a builder pattern could improve API discoverability. It may not be a good idea, but generally, For example: return RestResponse.fromUni(Uni.createFrom().item(new MyObject()))
.onItem()
.header(Map.of("Content-Disposition", "attachment;filename=" + outerParam)) // header (String, String), for header known before the Uni returned
.header("Content-Type", object -> object.contentType()) // header (String, Function<T, String>), when only the value vary
.header(object -> Map.of("Content-Length", List.of(object.length()))) // header (Function<T, Map<String, List<String>>>), for total control
.transformToMulti(object -> Multi.createFrom().publisher(object.getPublisher()))
.build(); Also, it feels bad that because we're doing things reactively, we lose the strongly typed helper method of |
Thanks for the suggestion. The problem is that the RestResponse models a very specific thing - a single HTTP response. When you are streaming data back however, that model doesn't work - you need something that represents the fact that you can only specify the headers once and then have a payload of multiple chunks. |
I should also mention that RestResponse works perfectly with Uni (you don't loose it's usefulness in the Reactive world). The problem as I mentioned above is the mismatch with the data streaming paradigm |
Hello! I have not yet upgraded to Quarkus 3 in my application yet. Is there a RestMulti equivalent for Quarkus 2 that could be used to stream bytes? Thank you. |
Hi, No, there is not really |
Huh... okay. Maybe it's time I look to upgrade then. |
Relates to: #33130
Closes: #26523