parameters

parameters

Extracts multiple query parameter values from the request.

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'");

Contents