本案例,将/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

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部