路由规则的匹配优先级

路由规则的匹配优先级

路由规则是从上到下匹配的,一旦匹配成功,就不会再考虑下面的规则。

现有以下两条路由规则:

        - id: admin_route
          uri: lb://renren-fast
          predicates:
            - Path=/api/**
          filters:
            - RewritePath=/api/(?/?.*), /renren-fast/$\{segment}

        - id: product_route
          uri: lb://gulimall-product
          predicates:
            - Path=/api/product/**
          filters:
            - RewritePath=/api/(?/?.*),/$\{segment}

可以看到第一条路由规则处理来自/api/**的请求,第二条路由规则处理来自/api/product/**的请求。当接收到形如/api/product/apple的请求时,网关会匹配第一条路由规则,第二条路哪怕更合适也会被跳过。

你可能感兴趣的:(服务器,微服务)