Skip to content

Instantly share code, notes, and snippets.

@Nimrod007
Created December 17, 2014 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nimrod007/b6df8e75559756898440 to your computer and use it in GitHub Desktop.
Save Nimrod007/b6df8e75559756898440 to your computer and use it in GitHub Desktop.
Spray with SimpleRoutingApp
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