专栏名称: 狗厂
目录
相关文章推荐
新闻夜航  ·  停!停!停!黑龙江一地发布...... ·  22 小时前  
新闻夜航  ·  突发讣告!他于凌晨1时去世 ·  昨天  
哈尔滨日报  ·  打一针就能根治春季过敏?国家卫健委辟谣 ·  昨天  
哈尔滨日报  ·  【数字有温度·TA的故事】点翠饰品一年卖出4 ... ·  2 天前  
51好读  ›  专栏  ›  狗厂

Spring Cloud Gateway离开孵化器的变化

狗厂  · 掘金  ·  · 2018-06-11 02:31

正文

文章目录
  1. 一.Spring Cloud Gateway概况
    1. 1.1 什么是Spring Cloud GateWay
    2. 1.2 Spring Cloud GateWay的功能
    3. 1.3 Spring Cloud GateWay离开孵化器
    4. 1.3 用Spring MVC的方式构建Gateway
      1. 1.3.1 How to Include Spring Cloud Gateway
      2. 1.3.2 Building a Gateway Using Spring MVC
  2. 二.Spring Cloud Gateway的MVC模块源码分析
    1. 2.1 构建Spring Cloud Gateway的Demo
    2. 2.2 Spring Cloud Gateway模块源码分析
    3. 2.3 代码分析

摘要 : Spring Cloud对Netflix的Zuul进行封装之后,Spring Cloud Zuul作为Spring Cloud的网关一直被大家使用用至今,在Spring Cloud的核心项目开发者 Spencergibb 的一篇博客 The API Gateway is Dead! Long Live the API Gateway! 中介绍了Zuul,Zuul 2以及为什么会有Spring Cloud Gateway,大家有兴趣可以看一下。本文将会对spring-cloud-gateway-mvc源码进行demo演示和简单分析。

一.Spring Cloud Gateway概况

1.1 什么是Spring Cloud GateWay

A Gateway built on Spring Framework 5.0 and Spring Boot 2.0 providing routing and more。

Spring Cloud Gateway是基于Spring 框架5.0版本和Spring Boot 2.0的版本构建,提供路由等功能。

1.2 Spring Cloud GateWay的功能

Spring Cloud GateWay具有以下特征

  • Java 8/Spring 5/Boot 2
  • WebFlux/Reactor
  • HTTP/2 and Websockets
  • Finchley Release Train (Q4 2017)

由于Spring 5.0支持Netty,Http2,而Spring Boot 2.0支持Spring 5.0,因此Spring Cloud Gateway支持Netty和Http2顺理成章。至于2017年Q4季度是否发布完整的Spring Cloud Gateway我们拭目以待。

1.3 Spring Cloud GateWay离开孵化器

从2016年12月份以后,在Github上出现了Spring Cloud Gateway的项目,地址为: github.com/spring-clou… ,如下图所示。

Spring Cloud GateWay离开孵化器之后master分支有MVC模块,需要查看完整的其它的模块请切换分支到 2.X 。因此在本文不分析core里面的设计和实现,后面将会补一篇文章介绍。


2.Spring Cloud Gateway的设计核心代码主要在spring-cloud-gateway-core,但是由于目前离开孵化器之后spring-cloud-gateway-core的代码挪到了 2.X 中,点击访问会自动转发到 github.com/spring-clou…


如上图所示,目前 master分支 中gateway没有core和starter,相对而言增加了一个 spring-cloud-gateway-mvc 模块,在下面章节将会对该模块进行demo和源码分析。

1.3 用Spring MVC的方式构建Gateway

1.3.1 How to Include Spring Cloud Gateway

To include Spring Cloud Gateway in your project add a dependency with group org.springframework.cloud and artifact id spring-cloud-gateway-mvc. See the Spring Cloud Project page for details on setting up your build system with the current Spring Cloud Release Train.







请到「今天看啥」查看全文