Skip to content

Instantly share code, notes, and snippets.

@nraychaudhuri
Created March 15, 2013 11:20
Show Gist options
  • Save nraychaudhuri/5169177 to your computer and use it in GitHub Desktop.
Save nraychaudhuri/5169177 to your computer and use it in GitHub Desktop.
Simple REST example in Play 2
//routes file
GET /ping/:message controllers.Application.restCall(message: String)
//Then my controller
object Application extends Controller {
case class SomeMessage(m: String)
implicit val someMessageFormat: Format[SomeMessage] = Json.format[SomeMessage]
def restCall(bar: String) = Action {
Async {
Akka.future(SomeMessage(s"pong ${bar}")).map(m => Ok(Json.toJson(m)))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment