Akka HTTP passthru response from Retrofit 2 client

java

(Felix Nensa) #1

Hi there,

I have an (Java) akka-http based webserver that sometimes has to query another HTTP service.
As there is an existing Retrofit 2 based client implementation for the other webservice I currently consume that webservice with Retrofit and need to pass the result somehow back to some kind of complete directive. The response from that webservice can be rather large and complex (multipart MIME, binary, non-binary) so I would like to stream it unmodified thru akka-http.

Now how would I do that? I can get a java.io.InputStream from the Retrofit response that I could probably convert to a Source with StreamConverters and pass this to a completeWithSource() directive. But what do I pass for Marshalling and EntityStreamingSupport then?
Or would I have to create a ResponseEntity like with HttpEntity.CloseDelimited(…), create a HttpResponse.create().withEntity(…) and pass that to the complete() directive. What works and would would be the best approach?

Because I have no control over clients and because of the network topology I cannot just complete with a redirect() directive.

Thanks,

Felix