extractSettings
Description
Extracts the RoutingSettings
from the RequestContext
.
By default the settings of the Http()
extension running the route will be returned. It is possible to override the settings for specific sub-routes by using the withSettings directive.
Example
final Route route = extractRequestContext(ctx -> {
ctx.getLog().debug("Using access to additional context available, like the logger.");
final HttpRequest request = ctx.getRequest();
return 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");