eureka
tanghc 4 years ago
parent 06f400fb81
commit f8b8e5fca1
  1. 8
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java
  2. 2
      sop-gateway/src/main/resources/META-INF/gateway.properties

@ -55,8 +55,14 @@ public class GatewayRouteRepository implements RouteRepository<GatewayTargetRout
RewritePathGatewayFilterFactory.Config config = new RewritePathGatewayFilterFactory.Config();
config.setRegexp(gatewayTargetRoute.getFullPath());
config.setReplacement(routeDefinition.getPath());
String serviceId = gatewayTargetRoute.getServiceDefinition().getServiceId();
String path = routeDefinition.getPath();
if (!path.startsWith("/")) {
path = "/" + path;
}
String finalPath = "/" + serviceId + path;
builder.route(routeDefinition.getId(),
r -> r.path(routeDefinition.getPath())
r -> r.path(finalPath)
// path匹配
.filters(gatewayFilterSpec -> gatewayFilterSpec.filter(rewritePathGatewayFilterFactory.apply(config)))
.uri(routeDefinition.getUri())

@ -35,7 +35,7 @@ spring.datasource.hikari.pool-name=HikariCP
spring.datasource.hikari.max-lifetime=500000
spring.cloud.gateway.discovery.locator.lower-case-service-id=true
spring.cloud.gateway.discovery.locator.enabled=true
#spring.cloud.gateway.discovery.locator.enabled=true
# \u54CD\u5E94\u8D85\u65F6\uFF0C\u9ED8\u8BA410\u79D2\uFF0810000\uFF09
spring.cloud.gateway.httpclient.response-timeout=10000
spring.cloud.gateway.httpclient.pool.max-idle-time=60000

Loading…
Cancel
Save