|
@@ -23,8 +23,10 @@ import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
|
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
|
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
|
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
|
|
|
+import org.springframework.util.AntPathMatcher;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
import org.springframework.util.MultiValueMap;
|
|
|
|
|
+import org.springframework.util.PathMatcher;
|
|
|
import org.springframework.web.reactive.function.server.HandlerStrategies;
|
|
import org.springframework.web.reactive.function.server.HandlerStrategies;
|
|
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
@@ -66,6 +68,9 @@ public class RequestDecoderFilter extends AbstractGatewayFilterFactory<Object> {
|
|
|
|
|
|
|
|
private static final List<String> FILE_TYPES = List.of("multipart/form-data");
|
|
private static final List<String> FILE_TYPES = List.of("multipart/form-data");
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private final PathMatcher pathMatcher = new AntPathMatcher();
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public GatewayFilter apply(Object config) {
|
|
public GatewayFilter apply(Object config) {
|
|
|
return (exchange, chain) -> {
|
|
return (exchange, chain) -> {
|
|
@@ -79,6 +84,11 @@ public class RequestDecoderFilter extends AbstractGatewayFilterFactory<Object> {
|
|
|
if (!filterUrl.isEmpty() && filterUrl.contains(path)) {
|
|
if (!filterUrl.isEmpty() && filterUrl.contains(path)) {
|
|
|
return chain.filter(exchange);
|
|
return chain.filter(exchange);
|
|
|
}
|
|
}
|
|
|
|
|
+ boolean match = filterUrl.stream().anyMatch(url -> pathMatcher.match(url, path));
|
|
|
|
|
+ if (match) {
|
|
|
|
|
+ return chain.filter(exchange);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (contentType != null && FILE_TYPES.stream().anyMatch(contentType.toString()::startsWith)) {
|
|
if (contentType != null && FILE_TYPES.stream().anyMatch(contentType.toString()::startsWith)) {
|
|
|
// 这是一个文件请求
|
|
// 这是一个文件请求
|
|
|
return chain.filter(exchange);
|
|
return chain.filter(exchange);
|