Like Monsieur Bort Says, You want to look at body parsers. I just got done puzzling these things out, and they are pretty nifty once you grok.
Here is basically what you need to know:
an Action is a trait that looks like this:
trait Action[A] extends (Request[A] => Result) {
def parser: BodyParser[A]
}
(oooh, its formatted!)
So an Action takes a Request[A], parses the body of the request using a BodyParser[A], and then returns a result. (makes sense, thats the nature of the web after all)
The Action trait comes with a
companion object, which is what you are used to using for your actions. The apply method of the Action object is what you typically use to construct a basic action. for example
def okpage = Action { request => Ok("ok") } //Action constructor takes a Function with the type Request => Result as its only argument
Here the body has already been parse according to some magical defaults that I don't know yet, but if we want to parse it using a different parser, so that the request is formatted differently, we can use a different apply method from the Action object, which is a curried function accepting first a body parser, and then the Request => Result function. It basically looks like this
def okpage = Action (parse.text) { request => Ok("body as text: " + request.body ) }
If you are wondering, as I did, where the heck `
parse` came from, it is a singleton object that you picked up with the import of BodyParsers. Check out the link to see some other useful predefined body parsers.
I hope that was helpful.