Spring Cloud Gateway 路由中的默认路径匹配

时间:2021-02-06 06:46:55

标签: spring spring-cloud-gateway

我正在尝试构建一个网关,其中基于 PATH 谓词为 2 个不同的微服务提供 3 条不同的路由。如果没有一条路径匹配,则它应该默认为一个特定的微服务。但我无法实现这一点。它从不执行默认路由。 理想情况下,如果没有任何谓词匹配,则默认配置应该最后执行。这是我的配置。感谢任何指针。

spring:
  application:
    name: account-apigateway

  cloud:
    gateway:
      
      routes:
        - id: accountService
          uri: ${account.service.url}
          order: 1000
          predicates:
            - Path=/service/**
          filters:
            - StripPrefix=1
        - id: viewer
          uri: ${account.viewer.url}
          order: 1000
          predicates:
            - Path=/viewer/**
        - id: app
          uri: ${account.app.url}
          order: 1000
          predicates:
            - Path=/app/**
        - id: app-corp
          order: 1000
          uri: ${account.app-corp.url}
          predicates:
            - Path=/app-corp/**    
        - id: default
          order: 1000000
          uri: ${account.viewer.url}
          predicates:
            - Path=/**      

0 个答案:

没有答案