Skip to content

Commit 6855a85

Browse files
committed
Move RequestPath to parent server package
1 parent 4630e62 commit 6855a85

37 files changed

+68
-49
lines changed

spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
import org.springframework.http.HttpMethod;
4040
import org.springframework.http.HttpRange;
4141
import org.springframework.http.MediaType;
42-
import org.springframework.http.server.reactive.PathContainer;
43-
import org.springframework.http.server.reactive.RequestPath;
42+
import org.springframework.http.server.PathContainer;
43+
import org.springframework.http.server.RequestPath;
4444
import org.springframework.http.server.reactive.ServerHttpRequest;
4545
import org.springframework.lang.Nullable;
4646
import org.springframework.util.Assert;
+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.http.server.reactive;
17+
package org.springframework.http.server;
1818

1919
import java.nio.charset.Charset;
2020
import java.nio.charset.StandardCharsets;

spring-web/src/main/java/org/springframework/http/server/reactive/DefaultRequestPath.java renamed to spring-web/src/main/java/org/springframework/http/server/DefaultRequestPath.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.http.server.reactive;
17+
package org.springframework.http.server;
1818

1919
import java.net.URI;
2020
import java.util.List;
@@ -44,7 +44,7 @@ class DefaultRequestPath implements RequestPath {
4444
this.pathWithinApplication = extractPathWithinApplication(this.fullPath, this.contextPath);
4545
}
4646

47-
DefaultRequestPath(RequestPath requestPath, @Nullable String contextPath) {
47+
private DefaultRequestPath(RequestPath requestPath, String contextPath) {
4848
this.fullPath = requestPath;
4949
this.contextPath = initContextPath(this.fullPath, contextPath);
5050
this.pathWithinApplication = extractPathWithinApplication(this.fullPath, this.contextPath);
@@ -104,6 +104,11 @@ public PathContainer pathWithinApplication() {
104104
return this.pathWithinApplication;
105105
}
106106

107+
@Override
108+
public RequestPath modifyContextPath(String contextPath) {
109+
return new DefaultRequestPath(this, contextPath);
110+
}
111+
107112

108113
@Override
109114
public boolean equals(@Nullable Object other) {

spring-web/src/main/java/org/springframework/http/server/reactive/PathContainer.java renamed to spring-web/src/main/java/org/springframework/http/server/PathContainer.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.http.server.reactive;
17+
package org.springframework.http.server;
1818

1919
import java.util.List;
2020

@@ -25,8 +25,7 @@
2525
* of {@link Separator Separator} and {@link PathSegment PathSegment} elements.
2626
*
2727
* <p>An instance of this class can be created via {@link #parsePath(String)} or
28-
* {@link #parseUrlPath(String)}. For an HTTP request the path can be
29-
* accessed via {@link ServerHttpRequest#getPath()}.
28+
* {@link #parseUrlPath(String)}.
3029
*
3130
* <p>For a URL path each {@link UrlPathSegment UrlPathSegment} exposes its
3231
* structure decoded safely without the risk of encoded reserved characters

spring-web/src/main/java/org/springframework/http/server/reactive/RequestPath.java renamed to spring-web/src/main/java/org/springframework/http/server/RequestPath.java

+13-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.http.server.reactive;
16+
package org.springframework.http.server;
1717

1818
import java.net.URI;
1919

@@ -32,8 +32,10 @@ public interface RequestPath extends PathContainer {
3232
* The context path is always at the beginning of the path and starts but
3333
* does not end with "/". It is shared for URLs of the same application.
3434
* <p>The context path may come from the underlying runtime API such as
35-
* when deploying as a WAR to a Servlet container or it may also be assigned
36-
* through the use of {@link ContextPathCompositeHandler} or both.
35+
* when deploying as a WAR to a Servlet container or it may be assigned in
36+
* a WebFlux application through the use of
37+
* {@link org.springframework.http.server.reactive.ContextPathCompositeHandler
38+
* ContextPathCompositeHandler}.
3739
*/
3840
PathContainer contextPath();
3941

@@ -42,6 +44,14 @@ public interface RequestPath extends PathContainer {
4244
*/
4345
PathContainer pathWithinApplication();
4446

47+
/**
48+
* Return a new {@code RequestPath} instance with a modified context path.
49+
* The new context path must match the beginning of this request path.
50+
* @param contextPath the new context path
51+
* @return a new {@code RequestPath} instance
52+
*/
53+
RequestPath modifyContextPath(String contextPath);
54+
4555

4656
/**
4757
* Create a new {@code RequestPath} with the given parameters.

spring-web/src/main/java/org/springframework/http/server/reactive/AbstractServerHttpRequest.java

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.springframework.http.HttpCookie;
2525
import org.springframework.http.HttpHeaders;
26+
import org.springframework.http.server.RequestPath;
2627
import org.springframework.lang.Nullable;
2728
import org.springframework.util.CollectionUtils;
2829
import org.springframework.util.LinkedMultiValueMap;

spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.springframework.http.HttpHeaders;
2323
import org.springframework.http.HttpMethod;
24+
import org.springframework.http.server.RequestPath;
2425
import org.springframework.lang.Nullable;
2526
import org.springframework.util.Assert;
2627

@@ -110,7 +111,7 @@ private RequestPath getRequestPathToUse(@Nullable URI uriToUse) {
110111
return null;
111112
}
112113
else if (uriToUse == null) {
113-
return new DefaultRequestPath(this.delegate.getPath(), this.contextPath);
114+
return this.delegate.getPath().modifyContextPath(this.contextPath);
114115
}
115116
else {
116117
return RequestPath.parse(uriToUse, this.contextPath);

spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequest.java

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.springframework.http.HttpMethod;
2323
import org.springframework.http.HttpRequest;
2424
import org.springframework.http.ReactiveHttpInputMessage;
25+
import org.springframework.http.server.RequestPath;
2526
import org.springframework.lang.Nullable;
2627
import org.springframework.util.MultiValueMap;
2728

spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.http.HttpCookie;
2626
import org.springframework.http.HttpHeaders;
2727
import org.springframework.http.HttpMethod;
28+
import org.springframework.http.server.RequestPath;
2829
import org.springframework.util.Assert;
2930
import org.springframework.util.MultiValueMap;
3031

spring-web/src/main/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.LinkedHashMap;
2020
import java.util.Map;
2121

22-
import org.springframework.http.server.reactive.PathContainer;
22+
import org.springframework.http.server.PathContainer;
2323
import org.springframework.lang.Nullable;
2424
import org.springframework.web.cors.CorsConfiguration;
2525
import org.springframework.web.server.ServerWebExchange;

spring-web/src/main/java/org/springframework/web/util/pattern/CaptureTheRestPathElement.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import java.util.List;
2020

21-
import org.springframework.http.server.reactive.PathContainer.Element;
22-
import org.springframework.http.server.reactive.PathContainer.UrlPathSegment;
21+
import org.springframework.http.server.PathContainer.Element;
22+
import org.springframework.http.server.PathContainer.UrlPathSegment;
2323
import org.springframework.util.LinkedMultiValueMap;
2424
import org.springframework.util.MultiValueMap;
2525
import org.springframework.web.util.pattern.PathPattern.MatchingContext;

spring-web/src/main/java/org/springframework/web/util/pattern/CaptureVariablePathElement.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.regex.Matcher;
2020
import java.util.regex.Pattern;
2121

22-
import org.springframework.http.server.reactive.PathContainer.UrlPathSegment;
22+
import org.springframework.http.server.PathContainer.UrlPathSegment;
2323
import org.springframework.lang.Nullable;
2424

2525
/**

spring-web/src/main/java/org/springframework/web/util/pattern/LiteralPathElement.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
package org.springframework.web.util.pattern;
1818

19-
import org.springframework.http.server.reactive.PathContainer;
20-
import org.springframework.http.server.reactive.PathContainer.Element;
21-
import org.springframework.http.server.reactive.PathContainer.PathSegment;
19+
import org.springframework.http.server.PathContainer;
20+
import org.springframework.http.server.PathContainer.Element;
21+
import org.springframework.http.server.PathContainer.PathSegment;
2222
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
2323

2424
/**

spring-web/src/main/java/org/springframework/web/util/pattern/ParsingPathMatcher.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.util.concurrent.ConcurrentMap;
2424
import java.util.stream.Collectors;
2525

26-
import org.springframework.http.server.reactive.PathContainer;
26+
import org.springframework.http.server.PathContainer;
2727
import org.springframework.lang.Nullable;
2828
import org.springframework.util.PathMatcher;
2929
import org.springframework.web.util.pattern.PathPattern.PathMatchResult;

spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24-
import org.springframework.http.server.reactive.PathContainer;
25-
import org.springframework.http.server.reactive.PathContainer.Element;
26-
import org.springframework.http.server.reactive.PathContainer.Separator;
24+
import org.springframework.http.server.PathContainer;
25+
import org.springframework.http.server.PathContainer.Element;
26+
import org.springframework.http.server.PathContainer.Separator;
2727
import org.springframework.lang.Nullable;
2828
import org.springframework.util.CollectionUtils;
2929
import org.springframework.util.MultiValueMap;

spring-web/src/main/java/org/springframework/web/util/pattern/RegexPathElement.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.regex.Matcher;
2222
import java.util.regex.Pattern;
2323

24-
import org.springframework.http.server.reactive.PathContainer.UrlPathSegment;
24+
import org.springframework.http.server.PathContainer.UrlPathSegment;
2525
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
2626

2727
/**

spring-web/src/main/java/org/springframework/web/util/pattern/SingleCharWildcardedPathElement.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.springframework.web.util.pattern;
1818

19-
import org.springframework.http.server.reactive.PathContainer.Element;
20-
import org.springframework.http.server.reactive.PathContainer.PathSegment;
19+
import org.springframework.http.server.PathContainer.Element;
20+
import org.springframework.http.server.PathContainer.PathSegment;
2121
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
2222

2323
/**

spring-web/src/main/java/org/springframework/web/util/pattern/WildcardPathElement.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.springframework.web.util.pattern;
1818

19-
import org.springframework.http.server.reactive.PathContainer;
20-
import org.springframework.http.server.reactive.PathContainer.Element;
19+
import org.springframework.http.server.PathContainer;
20+
import org.springframework.http.server.PathContainer.Element;
2121
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
2222

2323
/**
+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.http.server.reactive;
16+
package org.springframework.http.server;
1717

1818
import java.util.Arrays;
1919
import java.util.Collections;
@@ -22,7 +22,7 @@
2222

2323
import org.junit.Test;
2424

25-
import org.springframework.http.server.reactive.PathContainer.UrlPathSegment;
25+
import org.springframework.http.server.PathContainer.UrlPathSegment;
2626
import org.springframework.util.LinkedMultiValueMap;
2727
import org.springframework.util.MultiValueMap;
2828

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.http.server.reactive;
16+
package org.springframework.http.server;
1717

1818
import java.net.URI;
1919

spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternMatcherTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import org.junit.Test;
3030
import org.junit.rules.ExpectedException;
3131

32-
import org.springframework.http.server.reactive.PathContainer;
33-
import org.springframework.http.server.reactive.PathContainer.Element;
32+
import org.springframework.http.server.PathContainer;
33+
import org.springframework.http.server.PathContainer.Element;
3434
import org.springframework.util.AntPathMatcher;
3535
import org.springframework.web.util.pattern.PathPattern.PathMatchResult;
3636
import org.springframework.web.util.pattern.PathPattern.PathRemainingMatchInfo;

spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import org.junit.Test;
2424

25-
import org.springframework.http.server.reactive.PathContainer;
25+
import org.springframework.http.server.PathContainer;
2626
import org.springframework.web.util.pattern.PathPattern.PathMatchResult;
2727
import org.springframework.web.util.pattern.PatternParseException.PatternMessage;
2828

spring-webflux/src/main/java/org/springframework/web/reactive/config/PathMatchConfigurer.java

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class PathMatchConfigurer {
3030
@Nullable
3131
private Boolean trailingSlashMatch;
3232

33+
3334
@Nullable
3435
private Boolean caseSensitiveMatch;
3536

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.springframework.http.HttpRange;
4040
import org.springframework.http.MediaType;
4141
import org.springframework.http.codec.HttpMessageReader;
42-
import org.springframework.http.server.reactive.PathContainer;
42+
import org.springframework.http.server.PathContainer;
4343
import org.springframework.http.server.reactive.ServerHttpRequest;
4444
import org.springframework.http.server.reactive.ServerHttpResponse;
4545
import org.springframework.util.Assert;

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/PathResourceLookupFunction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.springframework.core.io.ClassPathResource;
2727
import org.springframework.core.io.Resource;
2828
import org.springframework.core.io.UrlResource;
29-
import org.springframework.http.server.reactive.PathContainer;
29+
import org.springframework.http.server.PathContainer;
3030
import org.springframework.util.ResourceUtils;
3131
import org.springframework.util.StringUtils;
3232
import org.springframework.web.util.pattern.PathPattern;

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.springframework.http.HttpCookie;
4040
import org.springframework.http.HttpMethod;
4141
import org.springframework.http.MediaType;
42-
import org.springframework.http.server.reactive.PathContainer;
42+
import org.springframework.http.server.PathContainer;
4343
import org.springframework.http.server.reactive.ServerHttpRequest;
4444
import org.springframework.lang.Nullable;
4545
import org.springframework.util.Assert;

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import org.springframework.http.MediaType;
3838
import org.springframework.http.codec.HttpMessageReader;
3939
import org.springframework.http.codec.json.Jackson2CodecSupport;
40-
import org.springframework.http.server.reactive.PathContainer;
40+
import org.springframework.http.server.PathContainer;
4141
import org.springframework.http.server.reactive.ServerHttpRequest;
4242
import org.springframework.lang.Nullable;
4343
import org.springframework.util.CollectionUtils;

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.springframework.http.HttpMethod;
3636
import org.springframework.http.HttpRange;
3737
import org.springframework.http.MediaType;
38-
import org.springframework.http.server.reactive.PathContainer;
38+
import org.springframework.http.server.PathContainer;
3939
import org.springframework.http.server.reactive.ServerHttpRequest;
4040
import org.springframework.util.Assert;
4141
import org.springframework.util.MultiValueMap;

spring-webflux/src/main/java/org/springframework/web/reactive/handler/AbstractUrlHandlerMapping.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import reactor.core.publisher.Mono;
2525

2626
import org.springframework.beans.BeansException;
27-
import org.springframework.http.server.reactive.PathContainer;
27+
import org.springframework.http.server.PathContainer;
2828
import org.springframework.lang.Nullable;
2929
import org.springframework.util.Assert;
3030
import org.springframework.util.StringUtils;

spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceUrlProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.springframework.context.ApplicationListener;
3232
import org.springframework.context.event.ContextRefreshedEvent;
3333
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
34-
import org.springframework.http.server.reactive.PathContainer;
34+
import org.springframework.http.server.PathContainer;
3535
import org.springframework.http.server.reactive.ServerHttpRequest;
3636
import org.springframework.util.StringUtils;
3737
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;

spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceWebHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import org.springframework.http.MediaType;
4242
import org.springframework.http.MediaTypeFactory;
4343
import org.springframework.http.codec.ResourceHttpMessageWriter;
44-
import org.springframework.http.server.reactive.PathContainer;
44+
import org.springframework.http.server.PathContainer;
4545
import org.springframework.lang.Nullable;
4646
import org.springframework.util.Assert;
4747
import org.springframework.util.CollectionUtils;

spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/PatternsRequestCondition.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.TreeSet;
2828
import java.util.stream.Collectors;
2929

30-
import org.springframework.http.server.reactive.PathContainer;
30+
import org.springframework.http.server.PathContainer;
3131
import org.springframework.lang.Nullable;
3232
import org.springframework.web.server.ServerWebExchange;
3333
import org.springframework.web.util.pattern.PathPattern;

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMapping.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.springframework.http.HttpMethod;
3232
import org.springframework.http.InvalidMediaTypeException;
3333
import org.springframework.http.MediaType;
34-
import org.springframework.http.server.reactive.PathContainer;
34+
import org.springframework.http.server.PathContainer;
3535
import org.springframework.http.server.reactive.ServerHttpRequest;
3636
import org.springframework.util.MultiValueMap;
3737
import org.springframework.web.method.HandlerMethod;

spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.springframework.context.support.GenericApplicationContext;
3232
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
3333
import org.springframework.http.CacheControl;
34-
import org.springframework.http.server.reactive.PathContainer;
34+
import org.springframework.http.server.PathContainer;
3535
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
3636
import org.springframework.mock.http.server.reactive.test.MockServerWebExchange;
3737
import org.springframework.web.reactive.HandlerMapping;

0 commit comments

Comments
 (0)