.NET Core微服务之基于Steeltoe集成Zuul实现统一API网关

Tip: 此篇已加入.NET Core微服务基础系列文章索引,本篇接上一篇《基于Steeltoe使用Eureka实现服务注册与发现》,所演示的示例也是基于上一篇的基础上而扩展的。

一、关于Spring Cloud Zuul

  API Gateway(API GW / API 网关),顾名思义,是出现在系统边界上的一个面向API的、串行集中式的强管控服务,这里的边界是企业IT系统的边界。

  Zuul 是Netflix 提供的一个开源组件,致力于在云平台上提供动态路由,监控,弹性,安全等边缘服务的框架,也有很多公司使用它来作为网关的重要组成部分。Spring Cloud 体系收录的该模块,主要用于提供动态路由、监控、安全控制、限流配额等,可以将内部微服务API同意暴露。

  

.NET Core微服务之基于Steeltoe集成Zuul实现统一API网关

  有关Zuul的更多内容,请参考我的这一篇:《Spring Cloud微服务架构学习笔记与示例》,这里不是本文重点,不再赘述。

二、快速构建Zuul Server

  (1)pom.xml添加相关依赖包:本示例的版本 => Spring Boot 1.5.15.RELEASE,Spring Cloud Edgware.SR3

<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <!-- zuul --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zuul</artifactId> </dependency> <!-- eureka --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <!-- 热启动,热部署依赖包,为了调试方便,加入此包 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies> <!-- spring cloud dependencies --> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Edgware.SR3</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsszgg.html