parameterMap
Extracts all parameters at once as a Map[String, String]
mapping parameter names to
parameter values.
Signature
def parameterMap: Directive[Map[String, String] :: HNil]
Description
If a query contains a parameter value several times, the map will contain the last one.
See When to use which parameter directive? for other choices.
Example
val route =
parameterMap { params =>
def paramString(param: (String, String)): String = s"""${param._1} = '${param._2}'"""
complete(s"The parameters are ${params.map(paramString).mkString(", ")}")
}
Get("/?color=blue&count=42") ~> route ~> check {
responseAs[String] === "The parameters are color = 'blue', count = '42'"
}
Get("/?x=1&x=2") ~> route ~> check {
responseAs[String] === "The parameters are x = '2'"
}