Skip to content

Instantly share code, notes, and snippets.

@Centaur
Created December 17, 2013 14:32
Show Gist options
  • Save Centaur/8005763 to your computer and use it in GitHub Desktop.
Save Centaur/8005763 to your computer and use it in GitHub Desktop.
spray service combiner
package com.cipinvestment
import spray.routing.{HttpService, Route}
import akka.actor.{ActorRefFactory, Actor}
trait ServiceCombiner extends HttpService {
val combinedRoute: List[Route] = Nil
}
trait Service1 extends ServiceCombiner {
abstract override val combinedRoute = {
get {
path("service1") {
complete("world")
}
}
} :: super.combinedRoute
}
trait Service2 extends ServiceCombiner {
abstract override val combinedRoute = {
get {
path("service2") {
complete("world")
}
}
} :: super.combinedRoute
}
class AllIn1Service extends Actor with ServiceCombiner with Service1 with Service2 {
def receive = runRoute(combinedRoute.reduce(_ ~ _))
implicit def actorRefFactory: ActorRefFactory = context
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment