From 0d3489f17e00690b6c3b5cd7cdbb0f2dfbf51f42 Mon Sep 17 00:00:00 2001 From: tanghc Date: Tue, 14 Jan 2020 09:29:03 +0800 Subject: [PATCH] 3.0.0 --- .../src/main/resources/sop-bridge.properties | 3 +++ .../sop/gatewaycommon/gateway/filter/IndexFilter.java | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sop-common/sop-bridge-gateway/src/main/resources/sop-bridge.properties b/sop-common/sop-bridge-gateway/src/main/resources/sop-bridge.properties index b5c2e2e3..f3085c07 100644 --- a/sop-common/sop-bridge-gateway/src/main/resources/sop-bridge.properties +++ b/sop-common/sop-bridge-gateway/src/main/resources/sop-bridge.properties @@ -3,6 +3,9 @@ spring.application.name=sop-gateway # 不用改,如果要改,请全局替换修改 sop.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC +# 网关入口 +gateway.index-path=/ + # nacos cloud配置 spring.cloud.nacos.discovery.server-addr=${nacos.url} diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/IndexFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/IndexFilter.java index 3019bf2b..5f2d8797 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/IndexFilter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/IndexFilter.java @@ -9,6 +9,7 @@ import com.gitee.sop.gatewaycommon.route.ForwardInfo; import com.gitee.sop.gatewaycommon.validate.Validator; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.gateway.support.BodyInserterContext; import org.springframework.cloud.gateway.support.CachedBodyOutputMessage; import org.springframework.core.Ordered; @@ -39,10 +40,12 @@ import java.util.Objects; @Order(Ordered.HIGHEST_PRECEDENCE) public class IndexFilter implements WebFilter { - private static final String INDEX_PATH = "/"; private static final String REST_PATH_PREFIX = "/rest"; private static final String SOP_PATH_PREFIX = "/sop"; + @Value("${gateway.index-path:/}") + private String indexPath; + @Autowired private Validator validator; @@ -67,7 +70,7 @@ public class IndexFilter implements WebFilter { ServerWebExchange newExchange = ServerWebExchangeUtil.getRestfulExchange(exchange, path); return chain.filter(newExchange); } - if (Objects.equals(path, INDEX_PATH)) { + if (Objects.equals(path, indexPath)) { if (request.getMethod() == HttpMethod.POST) { ServerRequest serverRequest = ServerWebExchangeUtil.createReadBodyRequest(exchange); // 读取请求体中的内容