extract

Description

The extract directive is used as a building block for Custom Directives to extract data from the RequestContext and provide it to the inner route.

See Providing Values to Inner Routes for an overview of similar directives.

Example

final Route route = extract(
  ctx -> ctx.getRequest().getUri().toString().length(),
  len -> complete("The length of the request URI is " + len)
);

// tests:
testRoute(route).run(HttpRequest.GET("/abcdef"))
  .assertEntity("The length of the request URI is 25");
The source code for this page can be found here.