spring cloud gateway的包结构(在Idea 2019.3中展示)
这个包是spring-cloud-gateway-core.这里是真正的spring-gateway的实现的地方.
为了证明,我们打开spring-cloud-starter-gateway的pom文件
org.springframework.cloud spring-cloud-starterorg.springframework.cloud spring-cloud-gateway-coreorg.springframework.boot spring-boot-starter-webflux
除了cloud-start,starter-webflux就是cloud-gateway-core.所以后面我们就分析
cloud-gateway-core这个jar包.
其中actuate中定义了GatewayControllerEndpoint,它提供了对外访问的接口.
// TODO: Flush out routes without a definition
@GetMapping("/routes")
public Flux
config包里定义了一些Autoconfiguration和一些properties.读取配置文件就在这里完成.
我们这里看一下GatewayProperties.java
@ConfigurationProperties("spring.cloud.gateway")
@Validated
public class GatewayProperties {
@NotNull
@Valid
private List routes = new ArrayList<>();
private List defaultFilters = new ArrayList<>();
private List streamingMediaTypes = Arrays
.asList(MediaType.TEXT_EVENT_STREAM, MediaType.APPLICATION_STREAM_JSON);
#该类包括三个属性,路由列表,默认过滤器列表和MediaType列表.路由列表中的路由定义RouteDefinition.
过滤器中定义的FilterDefinition.
discovery定义了注册中心的一些操作.
event定义了一系列事件,都继承自ApplicationEvent.
filter定义了spring gateway实现的一些过滤器,包括gatewayfilter,globalfilter.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



