pull/1/MERGE
tanghc 5 years ago
parent e1cd5c2298
commit 0d3489f17e
  1. 3
      sop-common/sop-bridge-gateway/src/main/resources/sop-bridge.properties
  2. 7
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/IndexFilter.java

@ -3,6 +3,9 @@ spring.application.name=sop-gateway
# 不用改,如果要改,请全局替换修改 # 不用改,如果要改,请全局替换修改
sop.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC sop.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC
# 网关入口
gateway.index-path=/
# nacos cloud配置 # nacos cloud配置
spring.cloud.nacos.discovery.server-addr=${nacos.url} spring.cloud.nacos.discovery.server-addr=${nacos.url}

@ -9,6 +9,7 @@ import com.gitee.sop.gatewaycommon.route.ForwardInfo;
import com.gitee.sop.gatewaycommon.validate.Validator; import com.gitee.sop.gatewaycommon.validate.Validator;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; 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.BodyInserterContext;
import org.springframework.cloud.gateway.support.CachedBodyOutputMessage; import org.springframework.cloud.gateway.support.CachedBodyOutputMessage;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
@ -39,10 +40,12 @@ import java.util.Objects;
@Order(Ordered.HIGHEST_PRECEDENCE) @Order(Ordered.HIGHEST_PRECEDENCE)
public class IndexFilter implements WebFilter { public class IndexFilter implements WebFilter {
private static final String INDEX_PATH = "/";
private static final String REST_PATH_PREFIX = "/rest"; private static final String REST_PATH_PREFIX = "/rest";
private static final String SOP_PATH_PREFIX = "/sop"; private static final String SOP_PATH_PREFIX = "/sop";
@Value("${gateway.index-path:/}")
private String indexPath;
@Autowired @Autowired
private Validator validator; private Validator validator;
@ -67,7 +70,7 @@ public class IndexFilter implements WebFilter {
ServerWebExchange newExchange = ServerWebExchangeUtil.getRestfulExchange(exchange, path); ServerWebExchange newExchange = ServerWebExchangeUtil.getRestfulExchange(exchange, path);
return chain.filter(newExchange); return chain.filter(newExchange);
} }
if (Objects.equals(path, INDEX_PATH)) { if (Objects.equals(path, indexPath)) {
if (request.getMethod() == HttpMethod.POST) { if (request.getMethod() == HttpMethod.POST) {
ServerRequest serverRequest = ServerWebExchangeUtil.createReadBodyRequest(exchange); ServerRequest serverRequest = ServerWebExchangeUtil.createReadBodyRequest(exchange);
// 读取请求体中的内容 // 读取请求体中的内容

Loading…
Cancel
Save