scala - How prevent spray run router at start up? -
consider code below:
import akka.actor.{actorsystem, props} import akka.io.io import spray.can.http object main extends app { implicit val system = actorsystem() val handler = system.actorof(props[demoserviceactor], name = "handler") io(http) ! http.bind(handler, interface = "localhost", port = 8080) } import akka.actor.actor import spray.routing.httpservice class demoserviceactor extends actor demoservice { def actorreffactory = context def receive = runroute(demoroute) } trait demoservice extends httpservice { implicit def executioncontext = actorreffactory.dispatcher def demoroute = { path("test") { { println("ping") complete("test complete") } } } }
when main
runs print console ping
. why? how fix this?
Comments
Post a Comment