Is there a way to convert javadsl Route to Flow? In Scala we have handlerFlow available implicitly, but in Java we have no analogues.
Tried to call handlerFlow, but it uses scaladsl types and incompatible with javadsl version of Route.
I want to use low-level version of API for ability to bind to http and https, and to be able to access connections.
==========================
Update:
I used idea from svezfaz's answer and now I get code:
Flow<HttpRequest, HttpResponse, NotUsed> createFlow(ActorSystem system, Materializer mat) {
scala.Function1<akka.http.scaladsl.server.RequestContext, scala.concurrent.Future<akka.http.scaladsl.server.RouteResult>> r = RouteImplementation.apply(createRoute());
Flow f = RouteResult$.MODULE$.route2HandlerFlow(
r,
RoutingSettings$.MODULE$.apply(system),
ParserSettings$.MODULE$.apply(system),
mat,
RoutingLog$.MODULE$.fromActorSystem(system),
null,
RejectionHandler$.MODULE$._mthdefault(),
null
).asJava();
return f;
}
It looks correct, but it doesn't compile. Probably, I have to include Scala Library into classpath. And then work a little with other Scala-to-Java type conversions.
I think it just easier to rewrite it w/o Routes in Java.