当前位置:网站首页>Gateway入门
Gateway入门
2022-07-28 17:06:00 【Minor王智】
1.Gateway
SpringCloud推出的一款基于WebFlux+Netty的Reactor响应式编程网关组件,性能相当于Zuul的一倍多。网关在分布式微服务架构中可以做很多事情:流控、日志监控、统一认证权限校验等。
Gateway中有3个重要概念:
- Route 路由:路由信息包括ID、URI、断言工厂、一组Filter。
- Predicates 断言:对请求的各种条件和参数校验,符合条件则放行。
- Filter 过滤器:对请求和响应的过滤链式处理。Gateway的Filter支持Pre和Post两种模式。
2.断言
Gateway官方提供了许多的内置断言类型:
- After:根据时间进行断言校验,仅指定日期之后才能放行。
- Before:和After相反。
- Between:在某两个时间之内放行。
- Cookie:校验指定的Cookie,符合条件的放行。
- Header:校验请求头。
- Host:校验匹配当前请求是否来自于设置的主机地址。
- Method:匹配HTTP请求方法,例如Post、Get等。
- Path:匹配路径。
- Query:参数匹配校验。
3.Filter过滤器
Gateway的过滤器支持Pre前置处理和Post后置处理两种模式,我们也可以实现Filter接口来自定义Gateway的过滤器,通过Order接口可以实现过滤器排序。
Gateway官方内置提供了数十种Filter,Filter分为两种:GatewayFilter、GlobalFilter。区别在于前者作用域具体的Route路由,后者属于全局过滤。一般情况下我们习惯用GlobalFilter,覆盖它的filter方法来实现请求的自定义操作,例如日志、认证授权、添加Header等操作。
边栏推荐
- Detailed explanation of network RJ45 interface
- .net swagger
- Cout.write learning
- Ue5 gas learning notes 8.0 references
- 连线:谁拥有未来的艺术?OpenAI允许Dall-E用户将作品商用化,目前而言
- Mongodb initialization operation
- How does Xiaobai learn software testing with zero foundation?
- Introduction to advanced design system (ads) 2009 RF simulation
- Ue5 gas learning notes 1.6 skills gameplay ability
- Ue5 gas learning notes 1.1 capability system component
猜你喜欢
随机推荐
Ue5 gas learning notes 1.8 game special effects (gameplaycue)
Look at Devops construction from SRE
Random talk on GIS data (VI) - projection coordinate system
NDK 系列(5):JNI 从入门到实践,爆肝万字详解!
Introduction to main parameters of antenna
Multithreading and high concurrency -- source code analysis AQS principle
冒泡排序和相关视频
haproxy实现灰度发布
Introduction to CC cable of USB type-C
Zen project management software is an indispensable tool for agile development teams
How to see the future development of software testing?
Is the training institution of software testing reliable
Brief introduction: basic principle of srv6
明德生物:公司暂未有产品被列入WHO推荐清单
连线:谁拥有未来的艺术?OpenAI允许Dall-E用户将作品商用化,目前而言
MQTT over QUIC:下一代物联网标准协议为消息传输场景注入新动力
mysql 索引使用与优化
Cout.write learning
Ue5 gas learning notes 1.10 prediction
有一种密码学专用语言叫做ASN.1









