Akka: Implicit conversion from route to flow for Http.bindAndHandle is a bit too magical

Created on 12 Mar 2016  路  4Comments  路  Source: akka/akka

(submitted at Konrad's request)

The Http.bindAndHandle call takes a Flow and there is a conversion from route to flow in the form of
RouteResult.route2HandlerFlow

Still not quite sure what happened, but I was unable to get this working until I added an explicit type to my routes declaration

val routeFlow: Flow[HttpRequest, HttpResponse, NotUsed] = ...

Now I've opted to be explicit:

val route = ...
val routeFlow: Flow[HttpRequest, HttpResponse, NotUsed] = RouteResult.route2HandlerFlow(route)

The documentation does mention the RouteResult method, at least on this page:
http://doc.akka.io/docs/akka/2.4.2/scala/http/routing-dsl/overview.html

But you might want to consider using it in samples, and/or including the explicit types on intermediate vals.

http

Most helpful comment

I had a similar issue and I eventually noticed that I did not have an ActorMaterializer in implicit scope. Once I had an ActorMaterializer in implicit scope, the implicit converter from Route to Flow was resolved.

All 4 comments

+1

Ticket moved to http://github.com/akka/akka-http
鈥≧ationale for the move discussed here: akka/akka-meta#27

If you are interested in contributing or tracking this issue, please comment in akka-http instead from now on :-)

I had a similar issue and I eventually noticed that I did not have an ActorMaterializer in implicit scope. Once I had an ActorMaterializer in implicit scope, the implicit converter from Route to Flow was resolved.

As noted above this issue has been moved to the akka-http repo, in this case https://github.com/akka/akka-http/issues/70

Was this page helpful?
0 / 5 - 0 ratings