parameter

parameter

Extracts a query parameter value from the request.

§Description

See parameter for a detailed description of this directive.

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

§Example

  1. final Route route = parameter("color", color ->
  2. complete("The color is '" + color + "'")
  3. );
  4.  
  5. // tests:
  6. testRoute(route).run(HttpRequest.GET("/?color=blue"))
  7. .assertEntity("The color is 'blue'");
  8.  
  9. testRoute(route).run(HttpRequest.GET("/"))
  10. .assertStatusCode(StatusCodes.NOT_FOUND)
  11. .assertEntity("Request is missing required query parameter 'color'");