IT袋

当前位置:主页 > 经验教程 > 软件教程 >

gateway网关配置参数

gateway网关配置参数 设备联网智能网关(3)

更新:2023-08-21 17:08:09 来源:IT袋 作者:苏晓敏
导读:gateway网关配置参数,Query Route Predicate 带指定查询参数的请求可以匹配该路由。 spring: cloud: gateway: routes: - id: user_query_byName uri: http://localhost:8080/user/query/byName predicates: - Query=na

gateway网关配置参数

gateway网关配置参数

Query Route Predicate

带指定查询参数的请求可以匹配该路由。

spring: cloud: gateway: routes: - id: user_query_byName uri: http://localhost:8080/user/query/byName predicates: - Query=name

在浏览器输入http://localhost:9201/user/query/byName?name=tom地址,发送请求。

gateway网关配置参数

Weight Route Predicate

使用权重来路由相应请求,以下配置表示有80%的请求会被路由到localhost:8080,20%的请求会被路由到localhost:8081。

spring: cloud: gateway: routes: - id: user_1 uri: http://localhost:8080 predicates: - Weight=group1, 8 - id: user_2 uri: http://localhost:8081 predicates: - Weight=group1, 2

RemoteAddr Route Predicate

从指定的远程地址发起的请求可以匹配该路由。

spring: cloud: gateway: routes: - id: user_1 uri: http://localhost:8080/user/getList predicates: - RemoteAddr=192.168.1.4

使用浏览器请求。

gateway网关配置参数

组合使用

spring: cloud: gateway: routes: - id: user_1 uri: http://localhost:8080/user/getList predicates: - RemoteAddr=192.168.1.4 - Method=POST - Cookie=username,yehongzhi - Path=/user/getList

使用POSTMAN发起请求,使用POST方式,uri是/user/getList,带有Cookie,RemoteAddr。

相关阅读