formFieldMultiMap
Signature
Description
Extracts all HTTP form fields at once as a multi-map of type Map[String, List[String]
mapping
a form name to a list of all its values.
This directive can be used if form fields can occur several times.
The order of values is not specified.
See formFields for an in-depth description.
Warning
Use of this directive can result in performance degradation or even in OutOfMemoryError
s.
See formFieldSeq for details.
Example
val route =
formFieldMultiMap { fields =>
complete("There are " +
s"form fields ${fields.map(x => x._1 + " -> " + x._2.size).mkString(", ")}")
}
// tests:
Post("/", FormData("color" -> "blue", "count" -> "42")) ~> route ~> check {
responseAs[String] shouldEqual "There are form fields color -> 1, count -> 1"
}
Post("/", FormData("x" -> "23", "x" -> "4", "x" -> "89")) ~> route ~> check {
responseAs[String] shouldEqual "There are form fields x -> 3"
}
Contents