mapRequestContext

mapRequestContext

Description

Transforms the RequestContext before it is passed to the inner route.

The mapRequestContext directive is used as a building block for Custom Directives to transform the request context before it is passed to the inner route. To change only the request value itself the mapRequest directive can be used instead.

See Transforming the Request(Context) for an overview of similar directives.

Example

final Route route = mapRequestContext(ctx ->
  ctx.withRequest(HttpRequest.create().withMethod(HttpMethods.POST)), () ->
  extractRequest(req -> complete(req.method().value()))
);

// tests:
testRoute(route).run(HttpRequest.GET("/abc/def/ghi"))
  .assertEntity("POST");

Contents