extractMatchedPath

Description

Extracts the matched path from the request context.

The extractMatchedPath directive extracts the path that was already matched by any of the PathDirectives (or any custom ones that change the unmatched path field of the request context). You can use it for building directives that use already matched part in their logic.

See also extractUnmatchedPath to see similar directive for unmatched path.

Example

final Route route = pathPrefix("abc", () -> extractMatchedPath(this::complete));

// tests:
testRoute(route).run(HttpRequest.GET("/abc")).assertEntity("/abc");
testRoute(route).run(HttpRequest.GET("/abc/xyz")).assertEntity("/abc");
The source code for this page can be found here.