本案例,将/helloworld-app/**的请求转发到helloworld微服务的/**路径(既如lb://helloworld/**)
配置如下(见spring.cloud.gateway.routes配置):
spring:
application:
name: SpringCloudGatewayDemo
cloud:
nacos:
discovery:
server-addr: localhost:8848
namespace: b62b1132-d8c6-4740-b745-75bcfb4f66a5
cluster-name: GD
gateway:
discovery:
locator:
# 让gateway通过服务发现组件找到其他的微服务
enabled: true
routes:
- id: helloworld_route
uri: lb://helloworld
predicates:
- Path=/helloworld-app/**
filters:
- RewritePath= /helloworld-app/(?<segment>.*), /${segment}
server:
port: 8099
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » Spring Cloud Gateway如何匹配某路径并进行路由转发
发表评论 取消回复