IT袋

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

gateway网关配置参数

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

更新:2023-08-21 17:08:09 来源:IT袋 作者:苏晓敏
导读:gateway网关配置参数,Header Route Predicate 带有指定请求头的请求会匹配该路由。 spring: cloud: gateway: routes: - id: user_getList uri: http://localhost:8080/user/getList predicates: - Header=X-Id, \d+ 使用

gateway网关配置参数

gateway网关配置参数

Header Route Predicate

带有指定请求头的请求会匹配该路由。

spring: cloud: gateway: routes: - id: user_getList uri: http://localhost:8080/user/getList predicates: - Header=X-Id, \d+

使用POSTMAN发送请求头带有X-Id的请求。

gateway网关配置参数

Host Route Predicate

带有指定Host的请求会匹配该路由。

spring: cloud: gateway: routes: - id: user_getList uri: http://localhost:8080/user/getList predicates: - Host=**.yehongzhi.com

使用POSTMAN发送请求头带有Host=www.yehongzhi.com的请求。

gateway网关配置参数

Path Route Predicate

发送指定路径的请求会匹配该路由。

spring: cloud: gateway: routes: - id: user_getList uri: http://localhost:8080/user/getList predicates: - Path=/user/getList

直接在浏览器输入该地址http://localhost:9201/user/getList,即可访问。

Method Route Predicate

发送指定方法的请求会匹配该路由。

spring: cloud: gateway: routes: - id: user_getList uri: http://localhost:8080/user/getList predicates: - Method=POST

用POSTMAN以POST方式发送请求。

相关阅读