parameterMultiMap

Description

Extracts all parameters at once as a multi-map of type Map<String, List<String>> mapping a parameter name to a list of all its values.

This directive can be used if parameters can occur several times.

The order of values is not specified.

See When to use which parameter directive? to understand when to use which directive.

Example

final Route route = parameterMultiMap(params -> {
  final String pString = params.entrySet()
    .stream()
    .map(e -> e.getKey() + " -> " + e.getValue().size())
    .collect(Collectors.joining(", "));
  return complete("There are parameters " + pString);
});

// tests:
testRoute(route).run(HttpRequest.GET("/?color=blue&count=42"))
  .assertEntity("There are parameters color -> 1, count -> 1");

testRoute(route).run(HttpRequest.GET("/?x=23&x=42"))
  .assertEntity("There are parameters x -> 2");
The source code for this page can be found here.