首页 > 其他 > 详细

gateway-路由方式说明

时间:2021-09-11 19:11:20      阅读:13      评论:0      收藏:0      [点我收藏+]

gateway 路由方式

1、cookie路由

spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
- Cookie=mycookie,mycookievalue
完全展开的参数
spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
- name: Cookie
args:
name: mycookie
regexp: mycookievalue
技术分享图片

 

 2 After route predicate /Before route predicate  / Between Route Predicate

spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
#在这时间之后可以访问
- After=2021-01-20T17:42:47.789-07:00[America/Denver]
spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
#在这时间之前可以访问
- Before=2020-01-20T17:42:47.789-07:00[America/Denver]
spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
#在这时间之间可以访问
- Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2023-01-21T17:42:47.789-07:00[America/Denver]

 3、Header Route Predicate

spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
#如果请求的标头名称X-Request-Id\d+正则表达式匹配(即,它的值为一位或多位数字),则此路由匹配
- Header=X-Request-Id, \d+

4、Host Route Predicate 主机路由

spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
#主机路由 即访问的主机地址
- Host=**.myxxljob.com,**.anotherhost.org

技术分享图片

 

 

5、Method Route Predicate 方法路由

spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
#方法路由
- Method=GET

 

6、Path Route Predicate  路径路由

spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
#路径路由
- Path=/red/{segment},/blue/{segment}

 

7、Query Route Predicate  查询路由

spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
#查询路由谓词工厂
- Query=green

 

8、RemoteAddr Route Predicate 

spring:
cloud:
gateway:
routes:
- id: remoteaddr_route
uri: https://example.org
predicates:
#RemoteAddr 路由
- RemoteAddr=192.168.1.1/24

 

9、Weight Route Predicate  权重路由

spring:
cloud:
gateway:
routes:
- id: weight_high
uri: https://weighthigh.org
predicates:
- Weight=group1, 5
- id: weight_low
uri: https://weightlow.org
predicates:
- Weight=group1, 5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 




















































技术分享图片

 

gateway-路由方式说明

原文:https://www.cnblogs.com/shufeiyang/p/15250756.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!