diff --git a/doc/docs/files/10100_提供restful接口.md b/doc/docs/files/10100_提供restful接口.md index c1218423..13ee9393 100644 --- a/doc/docs/files/10100_提供restful接口.md +++ b/doc/docs/files/10100_提供restful接口.md @@ -38,6 +38,15 @@ public class TraditionalWebappController { 请求前缀将变成:`http://ip:port/aaa/` +- 关闭restful功能 + +如果不想用该功能,在配置文件指定: + +```properties +# 开启restful请求,默认开启 +sop.restful.enable=false +``` + - 封装请求工具【可选】 封装请求,方便调用,针对vue的封装如下: 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 6903c71a..b21621b1 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 @@ -53,6 +53,10 @@ public class IndexFilter implements WebFilter { @Value("${sop.gateway-index-path:/}") private String indexPath; + /** sop.restful.enable=true ,开启restful请求,默认开启 */ + @Value("${sop.restful.enable:true}") + private boolean enableRestful; + @Autowired private Validator validator; @@ -68,7 +72,7 @@ public class IndexFilter implements WebFilter { return chain.filter(exchange); } // 如果是restful请求,直接转发 - if (path.startsWith(EnvironmentKeys.SOP_RESTFUL_PATH.getValue())) { + if (enableRestful && path.startsWith(EnvironmentKeys.SOP_RESTFUL_PATH.getValue())) { exchange.getAttributes().put(SopConstants.RESTFUL_REQUEST, true); String restfulPath = ServerWebExchangeUtil.getRestfulPath(path, EnvironmentKeys.SOP_RESTFUL_PATH.getValue()); ServerWebExchange newExchange = ServerWebExchangeUtil.getForwardExchange(exchange, restfulPath); diff --git a/sop-gateway/src/main/resources/META-INF/gateway.properties b/sop-gateway/src/main/resources/META-INF/gateway.properties index 8974b391..43f3979e 100644 --- a/sop-gateway/src/main/resources/META-INF/gateway.properties +++ b/sop-gateway/src/main/resources/META-INF/gateway.properties @@ -6,6 +6,9 @@ sop.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC # 网关入口 sop.gateway-index-path=/ +# 开启restful请求,默认开启 +sop.restful.enable=true + # nacos cloud配置 spring.cloud.nacos.discovery.server-addr=${register.url}