Reputation: 7794
This question has been asked for older versions of Akka Streams & Akka HTTP. akka-http: complete request with flow the problem with this answer is for each flow you need to materialise a new flow for each request which is not cheap.
A year later in the latest version what is the best way to integrate a flow with the routes DSL?
Again I have a complex Flow
I'd like to add to a route, if I map the flow to a Flow[HttpRequest, HttpResponse, _]
could I complete a route with this flow? Is there a better way or is the only way to use the low level API?
If thats the case whats the best way to do route mapping?
Upvotes: 2
Views: 407
Reputation: 9023
You are still required to materialize a new flow if you want to leverage Akka Streams DSL from a high-level Akka HTTP directive.
The good news is that Akka 2.5 changed the guts of the ActorMaterializer
quite a bit, allegedly improving its performance by 3-4x.
Faster and more flexible Akka Streams materializer, which matters for short lived streams, such as HTTP requests.
Upvotes: 1