Created
March 15, 2013 11:20
-
-
Save nraychaudhuri/5169177 to your computer and use it in GitHub Desktop.
Simple REST example in Play 2
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
//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