playframework/playframework — pull request #3136 by cchantep (2014-07-30 22:10:47+00:00)
Title: Function similar to servlet getParameterMap on request

When implementing some action proxyfing/forwarding request, it's useful to be able to get request parameters, from query string and body, like `HttpServletRequest.getParameterMap`.

```scala
val queryString = req.queryString.foldLeft(
Map[String, String]()) { (m, e) ⇒
val (k, v) = e
v.headOption.fold(m) { s ⇒ m + (k -> s) }
}

val post = (req.body match {
case AnyContentAsFormUrlEncoded(params) ⇒ params
case mp @ AnyContentAsMultipartFormData(_) ⇒
mp.asFormUrlEncoded getOrElse Map[String, Seq[String]]()
case _ ⇒ Map[String, Seq[String]]()
}).foldLeft(Map[String, String]()) { (m, e) ⇒
val (k, v) = e
v.headOption.fold(m) { s ⇒ m + (k -> s) }
}

val params: : Map[String, String] = post ++ queryString
```