We have bene using spray and pretty happy about it. The way we use spray on our production is like this.
------------------------------
trait HttpRootActor extends HttpService with TokenAuthenticator {
implicit def executionContext = actorRefFactory.dispatcher
implicit val timeout = ActorDict.timeout
val httpRootRoute = {
pathPrefix("t1") {
user: AppUser =>
ctx => ActorDict.testService1 ! ctx
} ~ pathPrefix("t2") {
user: AppUser =>
ctx => ActorDict.testService2 ! ctx
}
}
}
class TestService1 extends Actor with HttpTestService1 {
def actorRefFactory = context
def receive = runRoute(testService1tRoute)
}
trait HttpTestService1 extends HttpService {
implicit val timeout = ActorDict.timeout
implicit def executionContext = actorRefFactory.dispatcher
val testService1tRoute = {
post {
pathEnd {
import UserJsonProtocol._
import spray.httpx.SprayJsonSupport._
entity(as[User]) {
user => {
complete(Map("status"->"OK").toJson.compactPrint)
}
}
}
}
}
}
We are not quite sure how to do this with new AKKA http since there is no HttpService available any more.