Move RequestPath to parent server package
This commit is contained in:
parent
4630e62c20
commit
6855a85c41
|
|
@ -39,8 +39,8 @@ import org.springframework.http.HttpHeaders;
|
|||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRange;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.reactive.RequestPath;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.RequestPath;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.http.server.reactive;
|
||||
package org.springframework.http.server;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.http.server.reactive;
|
||||
package org.springframework.http.server;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
|
@ -44,7 +44,7 @@ class DefaultRequestPath implements RequestPath {
|
|||
this.pathWithinApplication = extractPathWithinApplication(this.fullPath, this.contextPath);
|
||||
}
|
||||
|
||||
DefaultRequestPath(RequestPath requestPath, @Nullable String contextPath) {
|
||||
private DefaultRequestPath(RequestPath requestPath, String contextPath) {
|
||||
this.fullPath = requestPath;
|
||||
this.contextPath = initContextPath(this.fullPath, contextPath);
|
||||
this.pathWithinApplication = extractPathWithinApplication(this.fullPath, this.contextPath);
|
||||
|
|
@ -104,6 +104,11 @@ class DefaultRequestPath implements RequestPath {
|
|||
return this.pathWithinApplication;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestPath modifyContextPath(String contextPath) {
|
||||
return new DefaultRequestPath(this, contextPath);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.http.server.reactive;
|
||||
package org.springframework.http.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -25,8 +25,7 @@ import org.springframework.util.MultiValueMap;
|
|||
* of {@link Separator Separator} and {@link PathSegment PathSegment} elements.
|
||||
*
|
||||
* <p>An instance of this class can be created via {@link #parsePath(String)} or
|
||||
* {@link #parseUrlPath(String)}. For an HTTP request the path can be
|
||||
* accessed via {@link ServerHttpRequest#getPath()}.
|
||||
* {@link #parseUrlPath(String)}.
|
||||
*
|
||||
* <p>For a URL path each {@link UrlPathSegment UrlPathSegment} exposes its
|
||||
* structure decoded safely without the risk of encoded reserved characters
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.http.server.reactive;
|
||||
package org.springframework.http.server;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
|
@ -32,8 +32,10 @@ public interface RequestPath extends PathContainer {
|
|||
* The context path is always at the beginning of the path and starts but
|
||||
* does not end with "/". It is shared for URLs of the same application.
|
||||
* <p>The context path may come from the underlying runtime API such as
|
||||
* when deploying as a WAR to a Servlet container or it may also be assigned
|
||||
* through the use of {@link ContextPathCompositeHandler} or both.
|
||||
* when deploying as a WAR to a Servlet container or it may be assigned in
|
||||
* a WebFlux application through the use of
|
||||
* {@link org.springframework.http.server.reactive.ContextPathCompositeHandler
|
||||
* ContextPathCompositeHandler}.
|
||||
*/
|
||||
PathContainer contextPath();
|
||||
|
||||
|
|
@ -42,6 +44,14 @@ public interface RequestPath extends PathContainer {
|
|||
*/
|
||||
PathContainer pathWithinApplication();
|
||||
|
||||
/**
|
||||
* Return a new {@code RequestPath} instance with a modified context path.
|
||||
* The new context path must match the beginning of this request path.
|
||||
* @param contextPath the new context path
|
||||
* @return a new {@code RequestPath} instance
|
||||
*/
|
||||
RequestPath modifyContextPath(String contextPath);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@code RequestPath} with the given parameters.
|
||||
|
|
@ -23,6 +23,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.server.RequestPath;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.net.URISyntaxException;
|
|||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.server.RequestPath;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
|
@ -110,7 +111,7 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
|||
return null;
|
||||
}
|
||||
else if (uriToUse == null) {
|
||||
return new DefaultRequestPath(this.delegate.getPath(), this.contextPath);
|
||||
return this.delegate.getPath().modifyContextPath(this.contextPath);
|
||||
}
|
||||
else {
|
||||
return RequestPath.parse(uriToUse, this.contextPath);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.springframework.http.HttpCookie;
|
|||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.ReactiveHttpInputMessage;
|
||||
import org.springframework.http.server.RequestPath;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.springframework.core.io.buffer.DataBuffer;
|
|||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.server.RequestPath;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.web.cors.reactive;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ package org.springframework.web.util.pattern;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer.Element;
|
||||
import org.springframework.http.server.reactive.PathContainer.UrlPathSegment;
|
||||
import org.springframework.http.server.PathContainer.Element;
|
||||
import org.springframework.http.server.PathContainer.UrlPathSegment;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.web.util.pattern;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer.UrlPathSegment;
|
||||
import org.springframework.http.server.PathContainer.UrlPathSegment;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package org.springframework.web.util.pattern;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.reactive.PathContainer.Element;
|
||||
import org.springframework.http.server.reactive.PathContainer.PathSegment;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.PathContainer.Element;
|
||||
import org.springframework.http.server.PathContainer.PathSegment;
|
||||
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import org.springframework.web.util.pattern.PathPattern.PathMatchResult;
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.reactive.PathContainer.Element;
|
||||
import org.springframework.http.server.reactive.PathContainer.Separator;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.PathContainer.Element;
|
||||
import org.springframework.http.server.PathContainer.Separator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer.UrlPathSegment;
|
||||
import org.springframework.http.server.PathContainer.UrlPathSegment;
|
||||
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
package org.springframework.web.util.pattern;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer.Element;
|
||||
import org.springframework.http.server.reactive.PathContainer.PathSegment;
|
||||
import org.springframework.http.server.PathContainer.Element;
|
||||
import org.springframework.http.server.PathContainer.PathSegment;
|
||||
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
package org.springframework.web.util.pattern;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.reactive.PathContainer.Element;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.PathContainer.Element;
|
||||
import org.springframework.web.util.pattern.PathPattern.MatchingContext;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.http.server.reactive;
|
||||
package org.springframework.http.server;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
|
@ -22,7 +22,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer.UrlPathSegment;
|
||||
import org.springframework.http.server.PathContainer.UrlPathSegment;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.http.server.reactive;
|
||||
package org.springframework.http.server;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
|
@ -29,8 +29,8 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.reactive.PathContainer.Element;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.PathContainer.Element;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.web.util.pattern.PathPattern.PathMatchResult;
|
||||
import org.springframework.web.util.pattern.PathPattern.PathRemainingMatchInfo;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.web.util.pattern.PathPattern.PathMatchResult;
|
||||
import org.springframework.web.util.pattern.PatternParseException.PatternMessage;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public class PathMatchConfigurer {
|
|||
@Nullable
|
||||
private Boolean trailingSlashMatch;
|
||||
|
||||
|
||||
@Nullable
|
||||
private Boolean caseSensitiveMatch;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.springframework.http.HttpMethod;
|
|||
import org.springframework.http.HttpRange;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import reactor.core.publisher.Mono;
|
|||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.pattern.PathPattern;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.springframework.core.ParameterizedTypeReference;
|
|||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.springframework.http.HttpRange;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.json.Jackson2CodecSupport;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.springframework.http.HttpHeaders;
|
|||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRange;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.springframework.context.ApplicationContext;
|
|||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import org.springframework.http.HttpStatus;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.MediaTypeFactory;
|
||||
import org.springframework.http.codec.ResourceHttpMessageWriter;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import java.util.SortedSet;
|
|||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.util.pattern.PathPattern;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.springframework.http.HttpHeaders;
|
|||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.InvalidMediaTypeException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.springframework.cache.concurrent.ConcurrentMapCache;
|
|||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerWebExchange;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ import org.springframework.http.HttpHeaders;
|
|||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRange;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.reactive.RequestPath;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.http.server.RequestPath;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import org.springframework.http.HttpHeaders;
|
|||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerWebExchange;
|
||||
|
|
|
|||
Loading…
Reference in New Issue