Description
using http:// instead of lb:// for the uri
property of routes definition only works if a RestClient.Builder
is declared as bean:
@LoadBalanced
@Bean
RestClient.Builder restClientBuilder() {
return RestClient.builder();
}
RestClient.Builder
bean is also required for this code:
@Bean
RouterFunction<ServerResponse> getRoute() {
return route().GET("/foo/**", http("http://foo-api"));
}
But with a RestClient.Builder
bean, lb:// prefix in yml routing configuration does not work (error 500).
If http:// is the way to go @Bean @LoadBalanced RestClient.Builder
could be provided by auto configuration (or documented as mandatory) and this page https://docs.spring.io/spring-cloud-gateway/reference/spring-cloud-gateway-server-mvc/filters/loadbalancer.html#_using_the_loadbalancer_filter_in_configuration should not mention lb:// prefix
Maybe I am wrong but it looks like "RouterFunction with http("...") only works if a @LoadBalancer @Bean RestClient.Builder
exists and then lb: prefix should not be used". I don't know if it is a bug or if it should be documented but it is not obvious.
With the webflux version a @LoadBalanced WebClient.Builder
bean does not break lb:// routings.
Metadata
Metadata
Assignees
Type
Projects
Status