playframework/playframework — pull request #1864 by dwhjames (2013-10-20 17:58:59+00:00)
Title: Lift mapM and flatMapM from Iteratee into BodyParser

The existing `map` and `flatMap` methods on `BodyParser` already lift the underlying `Iteratee` methods into `BodyParser`.

This commit does the same for the `mapM` and `flatMapM` methods, and for completeness-sake, it also lifts the `validate` method to `validateM`.

These combinators allow one to write code that asynchronously processes the results of body parsers, without having to touch the underlying `Iteratee` implementation.

```scala
def map [B](f: A ⇒ B): BodyParser[B]
def mapM[B](f: A ⇒ Future[B]): BodyParser[B]

def flatMap [B](f: A ⇒ BodyParser[B]): BodyParser[B]
def flatMapM[B](f: A ⇒ Future[BodyParser[B]]): BodyParser[B]

def validate [B](f: A ⇒ Either[SimpleResult, B]): BodyParser[B]
def validateM[B](f: A ⇒ Future[Either[SimpleResult, B]]): BodyParser[B]
```