閘道器的路徑解析和負載均衡
阿新 • • 發佈:2021-10-02
路徑解析
1.指定路徑 server: port: 8088 spring: application: name: GATEWAY cloud: consul: host: localhost port: 8500 gateway: routes: - id: category_route # 指定路由唯一標識 uri: http://localhost:8085 # 指定路由服務的地址 predicates: - Path=/category,/list # 指定路由規則 - id: product_route uri: http://localhost:8084 predicates: - Path=/product,/list 2.萬用字元 server: port: 8088 spring: application: name: GATEWAY cloud: consul: host: localhost port: 8500 gateway: routes: - id: category_route # 指定路由唯一標識 uri: http://localhost:8085 # 指定路由服務的地址 predicates: - Path=/category/** # 指定路由規則 - id: product_route uri: http://localhost:8084 predicates: - Path=/product/**
負載均衡
server: port: 8088 spring: application: name: GATEWAY cloud: consul: host: localhost port: 8500 gateway: routes: - id: category_route # 指定路由唯一標識 uri: lb://CATEGORY # 指定路由服務的地址 predicates: - Path=/category # 指定路由規則 - id: product_route uri: lb://PRODUCT #預設輪詢的方式 lb => loadbalance 格式: lb://服務名 predicates: - Path=/product