Created
December 17, 2014 19:54
-
-
Save Nimrod007/b6df8e75559756898440 to your computer and use it in GitHub Desktop.
Spray with SimpleRoutingApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor.ActorSystem | |
import spray.http.MediaTypes._ | |
import spray.routing.SimpleRoutingApp | |
object LightVersion extends App with SimpleRoutingApp { | |
implicit val system = ActorSystem("my-system") | |
startServer(interface = "0.0.0.0", port = 9119) { | |
path("api") { get { parameters('id.as[String]) | |
.as(Request) { request => { respondWithMediaType(`text/html`) { complete { | |
SomeService.calculateSomething(request.id)}}}}}}}} | |
case class Request(id: String) | |
object SomeService{ | |
def calculateSomething(id: String) = s"calculated something for id $id"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment