Hi Brice,
take a look at https://github.com/spray/spray/issues/780
I haven't tried it but as far as I understand, Route is just a type alias
for a Function1[RequestContext, Future[RouteResult]] and this function is
evaluated for every request, so if you do
def mainRoute: Route = Directives.concat(services.map(_.route)) ~
staticRoutes
Http().bindAndHandle(mainRoute, address, port)
It should just work.
Cheers,
Rafał
W dniu czwartek, 9 marca 2017 18:01:19 UTC+1 użytkownik Brice Figureau
napisał:
>
> Hi all,
>
> I've started migrating the spray part of my app to akka-http.
> In this app (an akka-cluster based system), I have an "administration"
> HTTP REST interface, that runs an akka-http server.
>
> In my system, all running actors have the possibility to register
> "administration commands" to this internal server (this is basically an
> actor). Each registered commands ends up as being a new route for the
> http server that when triggered delegates to the registered actor.
>
> Actually this is a bit more complex, because the actor that registers
> its commands only registers it to the local http server, but we might
> want to run this command by connecting to any node of the cluster (not
> the one where the actor is running), so there's a distributed data based
> system to share routes.
>
> In short, most of the routes are dynamically inserted and removed, based
> on actors that spawn (or stop) on nodes.
>
> When porting this part to akka-http, I was wondering how I could model
> this dynamic route system, since when calling:
> Http().bindAndHandle(routes, address, port)
>
> the `routes` parameter is a single Route, and as such the route itself
> is not re-evaluated on each connection.
>
> In Spray I was doing:
> def receive = runRoute {
> dynamic {
> services.map(_.route).reduce((a,b) => a ~ b)
> }
> ~
> ... static routes ...
> }
>
> I'm very unsure how I can migrate this part.
>
> Thanks for any suggestions!
> --
> Brice Figureau <[email protected] <javascript:>>
>
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.