简体   繁体   中英

About ID in route configuration of Spring Cloud Gateway

In Spring Cloud Gateway, in route configuration we can specify the 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? Does the stringvalue we give can be any value? What is its significance?

Just to mention that the new way of writing down the id on the RouteLocatorBuilder is

@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();
    }
```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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