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

您的位置:首頁技術文章
文章詳情頁

Spring cloud gateway工作流程原理解析

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

spring cloud gateway的包結構(在Idea 2019.3中展示)

Spring cloud gateway工作流程原理解析

這個包是spring-cloud-gateway-core.這里是真正的spring-gateway的實現的地方.

為了證明,我們打開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這個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); #該類包括三個屬性,路由列表,默認過濾器列表和MediaType列表.路由列表中的路由定義RouteDefinition. 過濾器中定義的FilterDefinition.

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

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

filter定義了spring gateway實現的一些過濾器,包括gatewayfilter,globalfilter.

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Spring
相關文章:
主站蜘蛛池模板: 欧美白人和黑人xxxx猛交视频 | 一级片成人 | 欧洲国产伦久久久久久久 | 9丨精品国产高清自在线看 ⅹxx中国xxx人妖 | 亚洲rct中文字幕在线 | 国产一级毛片午夜福 | 国产成人精品综合久久久软件 | 美女毛片儿 | 久久视频6免费观看视频精品 | 欧美一级片免费在线观看 | 欧美一区二区三区视频在线 | re久久| 欧美成人全部视频 | 国产亚洲人成网站在线观看不卡 | 神马我我不卡伦影视 | 亚洲欧美日韩中文字幕在线一 | 激情6月丁香婷婷色综合 | 久草视频网址 | 精品国产v无码大片在线观看 | 欧美aaaaa| 国产女厕所 | 欧美精品片在线观看网站 | 成人做爰在线视频 | 久久精品亚洲乱码伦伦中文 | 黑人一级片 | 欧美亚洲一区 | 国产欧美日韩综合精品一区二区三区 | 视频二区国产 | 岛国在线免费观看 | 国产成人一区二区三区在线播放 | 一级做a爱过程免费观看 | 国产精品久久一区一区 | 国产欧美日韩精品高清二区综合区 | 国产精品一区二区三区久久 | 国产看午夜精品理论片 | 大片毛片| 欧美一级久久 | 波多野吉衣 免费一区 | 久久亚洲精品成人 | 日本免费毛片在线高清看 | 日韩丝袜美腿 |