Spring Cloud Gateway如何匹配某路径并进行路由转发

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

相关推荐

  1. Spring Cloud Gateway如何匹配路径进行转发

    2024-07-09 19:50:05       26 阅读
  2. vue混入、、动态匹配

    2024-07-09 19:50:05       62 阅读
  3. react-router 的匹配逻辑

    2024-07-09 19:50:05       27 阅读
  4. Vue项目路径中去掉#

    2024-07-09 19:50:05       52 阅读
  5. python如何用glob模块匹配路径

    2024-07-09 19:50:05       42 阅读
  6. SpringCloudGateway

    2024-07-09 19:50:05       21 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 19:50:05       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 19:50:05       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 19:50:05       58 阅读
  4. Python语言-面向对象

    2024-07-09 19:50:05       69 阅读

热门阅读

  1. 裸金属服务器与物理服务器之间的区别

    2024-07-09 19:50:05       22 阅读
  2. 精准注入:掌握Conda包依赖注入的艺术

    2024-07-09 19:50:05       28 阅读
  3. Haproxy搭建Web群集

    2024-07-09 19:50:05       25 阅读
  4. 同步的艺术:Conda包依赖的自动同步策略

    2024-07-09 19:50:05       30 阅读
  5. Shell学习——Shell运算符

    2024-07-09 19:50:05       43 阅读
  6. ECharts 饼图:数据可视化的重要工具

    2024-07-09 19:50:05       32 阅读
  7. react之错误边界

    2024-07-09 19:50:05       25 阅读
  8. 代码随想录算法训练营:27/60

    2024-07-09 19:50:05       33 阅读
  9. Websocket

    2024-07-09 19:50:05       41 阅读
  10. 力扣56.合并区间

    2024-07-09 19:50:05       39 阅读