Extracts the matched path from the request context.
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.
import static akka.http.javadsl.server.Directives.extractMatchedPath; final Route route = pathPrefix("abc", () -> extractMatchedPath(Directives::complete)); // tests: testRoute(route).run(HttpRequest.GET("/abc")).assertEntity("/abc"); testRoute(route).run(HttpRequest.GET("/abc/xyz")).assertEntity("/abc");