Respect context path in WebMvc.fn & WebFlux.fn

This commit makes several changes in both WebMvc.fn as well as
WebFlux.fn.

 - ServerRequest now exposes a RequestPath through requestPath(), and
   pathContainer() has been deprecated.

 - The PathPredicate and PathResourceLookupFunction now respects this
   RequestPath's pathInApplication() in their path-related
   functionality.

 - When nesting, the PathPredicate now appends the matched part of the
   path to the current context path, instead of removing the matched
   part (which was done previously). This has the same result: the
   matched part is gone, but now the full path stays the same.

Closes gh-25270
This commit is contained in:
Arjen Poutsma
2020-09-03 15:10:36 +02:00
parent 88249b2d9a
commit d550d344d5
14 changed files with 122 additions and 137 deletions

View File

@@ -557,6 +557,7 @@ public class PathPatternTests {
pp = parse("/{this}/{one}/{here}");
pri = getPathRemaining(pp, "/foo/bar/goo/boo");
assertThat(pri.getPathRemaining().value()).isEqualTo("/boo");
assertThat(pri.getPathMatched().value()).isEqualTo("/foo/bar/goo");
assertThat(pri.getUriVariables().get("this")).isEqualTo("foo");
assertThat(pri.getUriVariables().get("one")).isEqualTo("bar");
assertThat(pri.getUriVariables().get("here")).isEqualTo("goo");
@@ -564,11 +565,13 @@ public class PathPatternTests {
pp = parse("/aaa/{foo}");
pri = getPathRemaining(pp, "/aaa/bbb");
assertThat(pri.getPathRemaining().value()).isEqualTo("");
assertThat(pri.getPathMatched().value()).isEqualTo("/aaa/bbb");
assertThat(pri.getUriVariables().get("foo")).isEqualTo("bbb");
pp = parse("/aaa/bbb");
pri = getPathRemaining(pp, "/aaa/bbb");
assertThat(pri.getPathRemaining().value()).isEqualTo("");
assertThat(pri.getPathMatched().value()).isEqualTo("/aaa/bbb");
assertThat(pri.getUriVariables().size()).isEqualTo(0);
pp = parse("/*/{foo}/b*");