简体   繁体   English

关于Spring云网关路由配置中的ID

[英]About ID in route configuration of Spring Cloud Gateway

In Spring Cloud Gateway, in route configuration we can specify the id在Spring Cloud Gateway中,在路由配置中我们可以指定id

@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
            .route(r -> r.path("/country/**")
                .uri("lb://COUNTRY-SERVICE/")
                //.id("<stringvalue>")
                )
            .route(r -> r.path("/**")
                    .uri("https://someothersite.com"))
            .build();
    }

What is.id("stringvalue") represent? is.id("stringvalue") 代表什么? Does the stringvalue we give can be any value?我们给的stringvalue可以是任意值吗? What is its significance?它的意义何在?

Just to mention that the new way of writing down the id on the RouteLocatorBuilder is只需提及在 RouteLocatorBuilder 上记下 id 的新方法是

@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
            .route("id", r -> r.path("/country/**")
                .uri("lb://COUNTRY-SERVICE/"))
            .route(r -> r.path("/**")
                    .uri("https://someothersite.com"))
            .build();
    }
```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM