当前位置: 首页 > news >正文

Spring Cloud Gateway

路由谓词工厂 Route Predicate Factory

1. The After Route Predicate Factory        

spring:cloud:gateway:routes:- id: after_routeuri: https://example.orgpredicates:- After=2017-01-20T17:42:47.789-07:00[America/Denver]# 用日期时间匹配

2. The Before Route Predicate Factory

spring:cloud:gateway:routes:- id: before_routeuri: https://example.orgpredicates:- Before=2017-01-20T17:42:47.789-07:00[America/Denver]# 用日期时间匹配

3. The Between Route Predicate Factory

spring:cloud:gateway:routes:- id: between_routeuri: https://example.orgpredicates:- Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]# 用日期时间匹配

4. The Cookie Route Predicate Factory        

spring:cloud:gateway:routes:- id: cookie_routeuri: https://example.orgpredicates:- Cookie=chocolate, ch.p# 用 cookie 名称和值匹配

5. The Header Route Predicate Factory       

spring:cloud:gateway:routes:- id: header_routeuri: https://example.orgpredicates:- Header=X-Request-Id, \d+# 用 header 名称和值匹配

6. The Host Route Predicate Factory      

spring:cloud:gateway:routes:- id: host_routeuri: https://example.orgpredicates:- Host=**.somehost.org,**.anotherhost.org# 用 Host header 的值匹配

7. The Method Route Predicate Factory        

spring:cloud:gateway:routes:- id: method_routeuri: https://example.orgpredicates:- Method=GET,POST# 用请求方法的类型匹配

8. The Path Route Predicate Factory        

spring:cloud:gateway:routes:- id: path_routeuri: https://example.orgpredicates:- Path=/red/{segment},/blue/{segment}# 用请求路径的值匹配

9. The Query Route Predicate Factory        

spring:cloud:gateway:routes:- id: query_routeuri: https://example.orgpredicates:- Query=green# 用查询参数的名称和值(值可以省略)匹配

10. The RemoteAddr Route Predicate Factory        

spring:cloud:gateway:routes:- id: remoteaddr_routeuri: https://example.orgpredicates:- RemoteAddr=192.168.1.1/24# 用 RemoteAddr(CIDR格式,如:192.168.1.1/24) header 的值匹配

11. The Weight Route Predicate Factory        

spring:cloud:gateway:routes:- id: weight_highuri: https://weighthigh.orgpredicates:- Weight=group1, 8- id: weight_lowuri: https://weightlow.orgpredicates:- Weight=group1, 2# 用分组名称和权重匹配

12. The XForwarded Remote Addr Route Predicate Factory        

spring:cloud:gateway:routes:- id: xforwarded_remoteaddr_routeuri: https://example.orgpredicates:- XForwardedRemoteAddr=192.168.1.1/24# 用 X-Forwarded-For(CIDR格式,如:192.168.1.1/24) header 值匹配

13. 自定义路由谓词工厂:继承自 AbstractRoutePredicateFactory

https://blog.csdn.net/abu935009066/article/details/112260405

网关过滤器工厂 GatewayFilter Factories

包括这些过滤器:

添加请求头、添加请求参数、添加响应头、断路器、缓存请求体、去重响应头、回退头、JSON转gRPC、本地响应缓存、映射请求头、修改请求体、修改响应体、前缀路径、保留主机头、重定向、移除JSON属性响应体、移除请求头、移除请求参数、移除响应头、请求头大小、请求速率限制器、重写位置响应头、重写路径、重写响应头、保存会话、安全头、设置路径、设置请求头、设置响应头、设置状态、去除前缀、重试、请求大小、设置请求主机头、令牌中继等过滤器和默认过滤器。

https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#gatewayfilter-factories

路由谓词和过滤器在 yml 中的两种配置方式

Shortcut annotation,简洁型写法:

spring:cloud:gateway:routes:- id: cookie_routeuri: https://example.orgpredicates:- Cookie=chocolate, ch.p    

Fully expanded arguments,复杂型写法(这种方式需要详细写出每一项):

spring:cloud:gateway:routes:- id: cookie_routeuri: https://example.orgpredicates:- name: Cookieargs: name: chocolateregexp: ch.p

http://www.lryc.cn/news/170739.html

相关文章:

  • JVM 优化技术
  • 【MySQL系列】- MySQL自动备份详解
  • 指针笔试题讲解-----让指针简单易懂(2)
  • 使用windbg分析dump文件的方法
  • 【论文阅读 07】Anomaly region detection and localization in metal surface inspection
  • SSM - Springboot - MyBatis-Plus 全栈体系(十一)
  • 深度剖析贪心算法:原理、优势与实战
  • Docker搭建DNS服务器--use
  • “顽固”——C语言用栈实现队列
  • linux内网渗透
  • 还没用熟 TypeScript 社区已经开始抛弃了
  • 2023年9月19日
  • PowerDesigner 与 mysql 同步数据
  • [python 刷题] 271 Encode and Decode Strings
  • [QT]day3
  • 《PostgreSQL事务管理深入解析》
  • 深度分析Oracle中的NULL
  • Python入门教学——类和对象
  • 【数据库系统概论】关系数据库中的关系数据结构
  • LabVIEW对Table中同一行数据分多次增加
  • 微信小程序实现删除功能
  • 整合Shiro+Jwt
  • Python 图形化界面基础篇:创建工具栏
  • 基于matlab实现的卡尔曼滤波匀加速直线运动仿真
  • windows Visual Studio 2022 opengl开发环境配置
  • 中国财政科学研究院党委书记、院长刘尚希一行莅临麒麟信安调研
  • 基于element-ui的年份范围选择器
  • 【已解决】您所使用的密钥ak有问题,不支持jsapi服务,可以访问该网址了解如何获取有效密钥。
  • JS操作数组方法学习系列(1)
  • 翻牌闯关游戏