parameters
Extracts multiple query parameter values from the request.
If an unmarshaller throws an exception while extracting the value of a parameter, the request will be rejected with a MissingQueryParameterRejection
if the unmarshaller threw an Unmarshaller.NoContentException
or a MalformedQueryParamRejection
in all other cases. (see also Rejections)
Description
See When to use which parameter directive? to understand when to use which directive.
Example
final Route route = parameter("color", color ->
parameter("backgroundColor", backgroundColor ->
complete("The color is '" + color
+ "' and the background is '" + backgroundColor + "'")
)
);
// tests:
testRoute(route).run(HttpRequest.GET("/?color=blue&backgroundColor=red"))
.assertEntity("The color is 'blue' and the background is 'red'");
testRoute(route).run(HttpRequest.GET("/?color=blue"))
.assertStatusCode(StatusCodes.NOT_FOUND)
.assertEntity("Request is missing required query parameter 'backgroundColor'");