The interfaces WebClient and RestClient both have generic - implementation agnostic - builders: WebClient.Builder and RestClient.Builder
Both the builders have - again implementation agnostic - methods WebClient.Builder.html#baseUrl(String) and RestClient.Builder.html#baseUrl(String)
Why then WebClient
and RestClient
don't have getters getBaseUrl()
to access the value set by the implementation agnostic builder, and why is it left to the implementation classes? When I construct a WebClient
or a RestClient
, I don't specify the implementation, so I would expect that the value passed via the implementation agnostic builder would be accessible from the implementation agnostic interface.
I have a use case to ask the object later what its base URL is, but I cannot do it without reflexion.
It would be nice to have getters also for other values passed to the builder.
Comment From: snicoll
@honza-zidek I am not sure I am following, what is the use case?
Comment From: honza-zidek
@snicoll A possible use case is e.g. in testing. Wherever you want to be sure which base URL has been actually set for a specific client.
I can't see any reason why, when the base URL is set in the implementation agnostic builder, the interface is missing a method to get the value, and you have to use reflexion.
Comment From: bclozel
If the use case is testing, then we're going to decline this enhancement request: you shouldn't test Spring Framework's code and if anything, you should test that the client generates URLs with the configured base.
Also, in the case of WebClient
, that information is lost as the base URL is turned into a UriBuilderFactory
, which is much more than a base URL. Same applies to RestClient
. So even if we agreed to, there is no easy way to implement the feature you're asking for. I'm closing this issue as a result. Thanks!