extractRequest

Description

Extracts the complete HttpRequest instance.

Use extractRequest to extract just the complete URI of the request. Usually there’s little use of extracting the complete request because extracting of most of the aspects of HttpRequests is handled by specialized directives. See Request Directives.

Example

final Route route = extractRequest(request ->
  complete("Request method is " + request.method().name() +
             " and content-type is " + request.entity().getContentType())
);

// tests:
testRoute(route).run(HttpRequest.POST("/").withEntity("text"))
  .assertEntity("Request method is POST and content-type is text/plain; charset=UTF-8");
testRoute(route).run(HttpRequest.GET("/"))
  .assertEntity("Request method is GET and content-type is none/none");
The source code for this page can be found here.