Spray is already based on akka.io
That way, if you just want to complete your route with an actorβs reaction, you can use a query template
import akka.pattern.ask import scala.concurrent.duration._ implicit val timeout = Timeout(5 seconds) // needed for `?` below val route = path("classify") { post { onComplete(actorResponse(yourActor, yourMessage)) { complete(_) } } } def actorResponse[T](actor: ActorRef, msg: ClassifyMessage): Future[T] = (actor ? msg).mapTo[T]
If you want to redirect a request to your model of your actor and complete the route somewhere in the acting system, you need to send RequestContext to the participants. Perhaps this example might help you. Good luck
source share