国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術(shù)文章
文章詳情頁

Spring cloud gateway工作流程原理解析

瀏覽:70日期:2023-09-07 09:18:58

spring cloud gateway的包結(jié)構(gòu)(在Idea 2019.3中展示)

Spring cloud gateway工作流程原理解析

這個(gè)包是spring-cloud-gateway-core.這里是真正的spring-gateway的實(shí)現(xiàn)的地方.

為了證明,我們打開spring-cloud-starter-gateway的pom文件

<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-gateway-core</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency> </dependencies>

除了cloud-start,starter-webflux就是cloud-gateway-core.所以后面我們就分析

cloud-gateway-core這個(gè)jar包.

Spring cloud gateway工作流程原理解析

其中actuate中定義了GatewayControllerEndpoint,它提供了對外訪問的接口.

// TODO: Flush out routes without a definition @GetMapping('/routes') public Flux<Map<String, Object>> routes() { return this.routeLocator.getRoutes().map(this::serialize); } @GetMapping('/routes/{id}') public Mono<ResponseEntity<Map<String, Object>>> route(@PathVariable String id) { //...... }//以下方法是繼承于父類,抽象類AbstractGatewayControllerEndpoint @PostMapping('/refresh') public Mono<Void> refresh() { this.publisher.publishEvent(new RefreshRoutesEvent(this)); return Mono.empty(); } @GetMapping('/globalfilters') public Mono<HashMap<String, Object>> globalfilters() { return getNamesToOrders(this.globalFilters); } @GetMapping('/routefilters') public Mono<HashMap<String, Object>> routefilers() { return getNamesToOrders(this.GatewayFilters); } @GetMapping('/routepredicates') public Mono<HashMap<String, Object>> routepredicates() { return getNamesToOrders(this.routePredicates); } @PostMapping('/routes/{id}') @SuppressWarnings('unchecked') public Mono<ResponseEntity<Object>> save(@PathVariable String id, @RequestBody RouteDefinition route) {} @DeleteMapping('/routes/{id}') public Mono<ResponseEntity<Object>> delete(@PathVariable String id) { return this.routeDefinitionWriter.delete(Mono.just(id)).then(Mono.defer(() -> Mono.just(ResponseEntity.ok().build()))).onErrorResume(t -> t instanceof NotFoundException, t -> Mono.just(ResponseEntity.notFound().build())); } @GetMapping('/routes/{id}/combinedfilters') public Mono<HashMap<String, Object>> combinedfilters(@PathVariable String id) { // TODO: missing global filters }

config包里定義了一些Autoconfiguration和一些properties.讀取配置文件就在這里完成.

Spring cloud gateway工作流程原理解析

我們這里看一下GatewayProperties.java

@ConfigurationProperties('spring.cloud.gateway')@Validatedpublic class GatewayProperties { /** * List of Routes. */ @NotNull @Valid private List<RouteDefinition> routes = new ArrayList<>(); /** * List of filter definitions that are applied to every route. */ private List<FilterDefinition> defaultFilters = new ArrayList<>(); private List<MediaType> streamingMediaTypes = Arrays .asList(MediaType.TEXT_EVENT_STREAM, MediaType.APPLICATION_STREAM_JSON); #該類包括三個(gè)屬性,路由列表,默認(rèn)過濾器列表和MediaType列表.路由列表中的路由定義RouteDefinition. 過濾器中定義的FilterDefinition.

discovery定義了注冊中心的一些操作.

event定義了一系列事件,都繼承自ApplicationEvent.

filter定義了spring gateway實(shí)現(xiàn)的一些過濾器,包括gatewayfilter,globalfilter.

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 国产乱码一区二区三区四 | 一区二区三区日韩精品 | 99精品视频在线播放2 | 国产精品久久久久久久久久免费 | 久草在线中文视频 | 欧美精品videos | julia中文字幕久久亚洲 | 中文字幕一二三区乱码老 | 国产精品久久在线观看 | 国产黄a三级三级看三级 | 手机在线一区二区三区 | 99九九99九九九视频精品 | 欧美性色xo影院在线观看 | 精品久久久久久亚洲 | 黄网站色视频免费观看w | 国产精品黑丝 | 二级毛片在线播放 | 国产成人a毛片在线 | 精品国产a| 久久国产成人精品 | www.碰| 99在线精品免费视频九九视 | 亚洲免费观看 | 国产操操 | 一级美国片免费看 | 欧美一区二区三区播放 | 亚洲国产精品免费在线观看 | 综合自拍亚洲综合图区美腿丝袜 | 美女视频黄免费 | 国产一区二区三区在线免费 | 欧美中文字幕在线视频 | 欧美成人黄色网 | 国产手机在线视频 | 91高端极品外围在线观看 | 手机看片国产日韩 | 欧美日韩国产一区二区三区在线观看 | 一级做a爱片特黄在线观看 一级做a爱片特黄在线观看免费看 | 欧美一级毛片在线观看 | 高颜值美女啪啪 | 亚洲欧美日本韩国综合在线观看 | 欧美日韩亚洲v在线观看 |