Last active
April 12, 2016 18:30
-
-
Save ignasi35/65f729a9a65aa6296933b100026a0fa1 to your computer and use it in GitHub Desktop.
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
package com.marimon.meetup | |
import com.marimon.meetup.providers._ | |
import com.marimon.meetup.providers.MyBookStoreProtocol.cdFormat | |
import spray.routing.SimpleRoutingApp | |
import spray.httpx.SprayJsonSupport._ | |
import com.marimon.meetup.providers.MyBookStoreProtocol._ | |
object Main extends App with SimpleRoutingApp { | |
val u2 = Group("U2", Some(List(Person("Bono"), Person("TheEdge")))) | |
val gorillaz = Group("Gorillaz", None) | |
var stock = | |
List(CDDVD(u2, "Joshua Tree", List(Song("Where the streets have no name", 338), Song("With or without you", 296))), | |
CDDVD(gorillaz,"Demon Days", List(Song("Intro", 63), Song("Feel Good Inc.", 221)))) | |
startServer(interface = "localhost", port = 8080) { | |
path("books.json"){ | |
get{ | |
complete(stock) | |
} | |
~ post( | |
entity(as[CDDVD[Group]]) { newItem => | |
complete { | |
stock = newItem :: stock | |
"added: " + newItem | |
} | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment