工作流程图

配置示例

application.yml

spring:cloud:gateway:routes:- id: after_routeuri: https://example.orgpredicates:- Cookie=mycookie,mycookievalue

断言配置类型

1 After

spring:cloud:gateway:routes:- id: after_routeuri: https://example.orgpredicates:- After=2017-01-20T17:42:47.789-07:00[America/Denver]

2 Before

spring:cloud:gatewayroutes:- id: before_routeuri: https://example.orgpredicates:- Before=2017-01-20T17:42:47.789-07:00[America/Denver]

3 Between

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 Cookie

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

5 Header

spring:cloud:gateway:routes:- id: header_routeuri: https://example.orgpredicates:- Header=X-Request-Id, \d+

6 Host

spring:cloud:gateway:routes:- id: host_routeuri: https://example.orgpredicates:- Host=**.somehost.org,**.anotherhost.org

7 Method

spring:cloud:gateway:routes:- id: method_routeuri: https://example.orgpredicates:- Method=GET,POST

8 Path

spring:cloud:gateway:routes:- id: path_routeuri: https://example.orgpredicates:- Path=/red/{segment},/blue/{segment}

9 Query 请求参数包含green 或 re 可以使用正则配置

spring:cloud:gateway:routes:- id: query_routeuri: https://example.orgpredicates:- Query=green, re.

10 RemoteAddr

spring:cloud:gateway:routes:- id: remoteaddr_routeuri: https://example.orgpredicates:- RemoteAddr=192.168.1.1/24

11 Weight

spring:cloud:gateway:routes:- id: weight_highuri: https://weighthigh.orgpredicates:- Weight=group1, 8- id: weight_lowuri: https://weightlow.orgpredicates:- Weight=group1, 2

12 XForwardedRemoteAddr

spring:cloud:gateway:routes:- id: xforwarded_remoteaddr_routeuri: https://example.orgpredicates:- XForwardedRemoteAddr=192.168.1.1/24

GatewayFilter 有限流,熔断,负载功能

1 AddRequestHeader

spring:cloud:gateway:routes:- id: add_request_header_routeuri: https://example.orgpredicates:- Path=/red/{segment}filters:- AddRequestHeader=X-Request-Red, Blue-{segment}

2 AddRequestParameter

spring:cloud:gateway:routes:- id: add_request_parameter_routeuri: https://example.orgpredicates:- Host: {segment}.myhost.orgfilters:- AddRequestParameter=foo, bar-{segment}

3 AddResponseHeader

spring:cloud:gateway:routes:- id: add_response_header_routeuri: https://example.orgpredicates:- Host: {segment}.myhost.orgfilters:- AddResponseHeader=foo, bar-{segment}

GlobalFilter

主要进行拦截所有的请求,做一些排序,url覆盖修改等操作;在未来的版本中可能该接口被修改;

自定义断言

继承AbstractRoutePredicateFactory

自定义GatewayFilter

继承 AbstractGatewayFilterFactory

自定义GlobalFilter

实现GlobalFilter

使用网关动态路由

gateway使用教程相关推荐

  1. Apache Dubbo RSocket Gateway 入门教程

    Apache Dubbo是一个流行的Java RPC框架,尤其是在中国.有很多项目使用Dubbo.虽然它正在通过适配Reactive Streams 和 Service Mesh来实现未来的新版本Du ...

  2. SpringCloud 2020版本教程2:使用spring cloud gateway作为服务网关

    点击关注公众号,Java干货及时送达 Spring Cloud Gateway是Spring Cloud官方推出的第二代网关框架,取代Zuul网关.网关作为流量的,在微服务系统中有着非常作用,网关常见 ...

  3. springcloud gateway ribbon使用_Github点赞接近 70k 的Spring Cloud学习教程+实战项目推荐!牛批!...

    这篇文章继续来推荐 Spring Cloud 的教程和实战项目了!想必不用不多说,大家都知道 Spring Cloud 的重要程度.几乎稍微有点规模的公司,一般都离不开要和微服务打交道.同时,Spri ...

  4. Spring Cloud学习笔记—网关Spring Cloud Gateway官网教程实操练习

    Spring Cloud学习笔记-网关Spring Cloud Gateway官网教程实操练习 1.Spring Cloud Gateway介绍 2.在Spring Tool Suite4或者IDEA ...

  5. 微服务网关:SpringCloud Gateway保姆级入门教程

    什么是微服务网关 SpringCloud Gateway是Spring全家桶中一个比较新的项目,Spring社区是这么介绍它的: 该项目借助Spring WebFlux的能力,打造了一个API网关.旨 ...

  6. SpringCloud系列教程(五)之SpringCloud Gateway 网关聚合开发文档 swagger knife4j 和登录权限统一验证【Hoxton版】

    阅读提醒: 本文面向的是有一定springboot基础者 本次教程使用的Spring Cloud Hoxton RELEASE版本 由于knife4j比swagger更加友好,所以本文集成knife4 ...

  7. 什么是微服务网关?SpringCloud Gateway保姆级入门教程

    什么是微服务网关 SpringCloud Gateway是Spring全家桶中一个比较新的项目,Spring社区是这么介绍它的: 该项目借助Spring WebFlux的能力,打造了一个API网关.旨 ...

  8. Gateway服务网关使用教程

    目录 1.为什么需要网关 2.gateway快速入门 1)创建gateway服务,引入依赖 2)编写启动类 3)编写基础配置和路由规则 4)重启测试 5)网关路由的流程图 3.断言工厂 4.过滤器工厂 ...

  9. go语言使用grpc和gateway教程

    jsonrpc 把jsonrpc.ServeConn(conn)改为grpc.ServeConn(conn)就是grpc了 为什么用jsongrpc? 因为grpc使用的为go语言独有的数据序列化go ...

最新文章

  1. java并发核心知识体系精讲_JAVA核心知识汇总
  2. mybatis的优缺点
  3. 65个免费和高质量的纹理包
  4. return true Java方法_java - 如何检查方法是否返回true或false?_java_酷徒编程知识库...
  5. 配置View桌面时找不到域的解决方法
  6. 男朋友的回答可以多敷衍?
  7. YbtOJ#853-平面标记【整体二分,凸壳】
  8. 剑指Offer - 面试题60. n个骰子的点数(动态规划)
  9. Zookeeper-Watcher(事件通知)
  10. linux命令和应用程序,在Linux中开发C应用程序时的重要且方便的工具和命令
  11. 【14:00开播】国际顶会强力加持,算法“视”界杯巅峰之战拉开帷幕!
  12. 关于window.showModalDialog遭遇frameset不能初始化对话框大小
  13. HDU1576 A/B【扩展欧几里得算法+试探法】
  14. H3C VLAN同步MVRP实验
  15. 分布式MySQL集群方案,看看京东是怎么做的
  16. 数据库 聚合 、分组、筛选、排序、日期等函数的应用
  17. vue 直传视频到阿里云OSS
  18. 微软商店打不开,闪退,或者根本没反应
  19. html设置首页到尾页的按钮,AspNetPager里面的按钮(如:首页,上一页 下一页,尾页)如何更换为我想要的图片...
  20. java高仿新浪微博短链接地址生成工具ShortUrlGenerator.java

热门文章

  1. 笔试——2019方正FPGA
  2. 登陆验证码图片不显示解决办法
  3. 返璞归真-删除文件默认打开方式
  4. 服务器监控1-Serveragent
  5. android 仿钢笔代码,仿ps画布钢笔抠图工具代码
  6. Toast的简单用法
  7. Nginx做缓存服务器
  8. 迪拓房地产展厅设计,一个可以帮地产企业卖房的展厅!
  9. 字符串转JSON字符串报错
  10. 配置赛门铁克(Symantec)https证书:从阿里云申请免费赛门铁克(Symantec)https证书并配置到cdn