I haven\'t found a solid example or structure to splitting up Spray.io routes into multiple files. I am finding that the current structure of my routes are going to become v
You can combine routes from different "Controllers" using ~ combinator.
class AccountServiceActor extends Actor with HttpService {
def actorRefFactory = context
def receive = handleTimeouts orElse runRoute(
new AccountService1.accountService1 ~ new AccountService2.accountService2)
def handleTimeouts: Receive = {
case Timeout(x: HttpRequest) =>
sender ! HttpResponse(StatusCodes.InternalServerError, "Request timed out.")
}
}
class AccountService1 extends HttpService {
val accountService1 = {
get {
path("") {
respondWithMediaType(`text/html`) { // XML is marshalled to `text/xml` by default, so we simply override here
complete(index)
}
}
}
}
class AccountService2 extends HttpService {
val accountService2 = {
get {
path("someotherpath") {
respondWithMediaType(`text/html`) { // XML is marshalled to `text/xml` by default, so we simply override here
complete(index)
}
}
}
}