You can see the source code to the net-a-porter Spray example here: https://github.com/NET-A-PORTER/spray-actor-per-request/blob/master/src/main/scala/com/netaporter/Boot.scala
The startup looks like: IO(Http) ! Http.Bind(serviceActor, "localhost", port = 38080) where "serviceActor" is an actor that mixes in spray.routing.HttpService, as you say. The actor uses that trait to call "runRoute" to bind its Route to the HTTP layer. In Akka HTTP, you instead need to wrap a Route with "akka.http.scaladsl.server.Route.handlerFlow" to turn it into a Flow[HttpRequest, HttpResponse, Unit] and then pass that into "Http().bindAndHandle(...)". See http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-M5/scala/http/server.html for more on the new API. That part has changed quite a bit, but from the Routing layer on down, everything is very much the same, in my opinion. On Tuesday, June 16, 2015 at 4:41:54 AM UTC+1, Nicolau Werneck wrote: > > All right then, except I'm under the impression that to use that pattern > we need to create an application using the `spray.routing.HttpService` > class, and I could not find it in akka-http. Is it available under a > different name? > > Thanks, > ++nic > > > On Monday, June 15, 2015 at 3:51:27 PM UTC-3, Richard Bradley wrote: >> >> The situation is very much the same in Akka HTTP as it was in Spray 1.3. >> You should be able to translate the actor-per-request pattern into Akka >> with only superficial changes. >> If you didn't deal with large (streamed / chunked) requests, everything >> is very much the same from Routing on down. >> >> As to which is recommended -- I think that is much the same as well: >> >> Actor-per-request needs more book-keeping (to avoid leaks) but allows >> greater control in complex scenarios. >> >> Future calls (which can include "asks" on Actors) are simpler and usually >> more type-safe and easier to work with IMO. You need to be very careful >> around mutable state though. >> >> HTH, >> >> >> Rich >> >> >> On Monday, June 15, 2015 at 4:50:54 AM UTC+1, Nicolau Werneck wrote: >>> >>> From what I gathered from the documentation and examples, the usual way >>> to answer to a request asynchronously in Spray and akka-http is to >>> `complete` with a `Future`, which may be produced from asking an actor. But >>> in Spray there was also the so-called "actor per-request" pattern, >>> documented in >>> http://techblog.net-a-porter.com/2013/12/ask-tell-and-per-request-actors/ >>> >>> Is that still possible to do with akka-http? And is it discouraged in >>> general? Should we really stick to using Futures to integrate akka-http to >>> the rest of our applications? >>> >>> ++nic >>> >>> -- >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.