Hello!
Is it possible to return data as stream (like spring StreamingResponseBody) in Hilla @Endpoint?
Using Flux is prohibited.
I need non reactive solution except for creating spring controller, as it requires creating client manually.
Flux is the way of streaming a response in Hilla. Note that you can technically use Flux only for streaming out data through a consumer from a custom sink without making anything in the application reactive.
If that’s not possible for you, then you’d have to do that functionality through regular Spring MVC controller and implement the client-side separately. The rest of the application can still use Hilla.
I just added @Controller in addition to @Endpont for endpoint class and marked the method as
@GetMapping(path = "/log-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
it is not possible to call directly from Hilla client, but accessible via
const source = new EventSource(
`${window.location.origin}/log-stream`
);
Note that you might also have to ensure that access control works as expected also for that method.
http://localhost:8098/log-stream
works if I logged in, and sends to Login view, If I logged out