mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-13 05:59:01 +08:00
⬆️ 依赖升级。 F SR2 、Boot 2.0.6
This commit is contained in:
1 parent
5f01480498
commit
76f2ef1940
2 files changed
+5
-12
No files matched your search
+2
-9
@@ -18,7 +18,6 @@
|
||||
package com.pig4cloud.pigx.gateway.filter;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.gateway.config.SwaggerProvider;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -42,7 +41,8 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.a
|
||||
* <p>
|
||||
* 1. 对请求头中参数进行处理 from 参数进行清洗
|
||||
* 2. 重写StripPrefix = 1,支持全局
|
||||
* 3. 支持swagger添加X-Forwarded-Prefix header
|
||||
* <p>
|
||||
* 支持swagger添加X-Forwarded-Prefix header (F SR2 已经支持,不需要自己维护)
|
||||
*/
|
||||
@Component
|
||||
public class PigxRequestGlobalFilter implements GlobalFilter, Ordered {
|
||||
@@ -73,15 +73,8 @@ public class PigxRequestGlobalFilter implements GlobalFilter, Ordered {
|
||||
.build();
|
||||
exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI());
|
||||
|
||||
// 3. 支持swagger添加X-Forwarded-Prefix header
|
||||
String path = request.getURI().getPath();
|
||||
if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) {
|
||||
return chain.filter(exchange.mutate().request(newRequest).build());
|
||||
}
|
||||
String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI));
|
||||
return chain.filter(exchange.mutate()
|
||||
.request(newRequest.mutate()
|
||||
.header(HEADER_NAME, basePath)
|
||||
.build()).build());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user