英文:
Identifying UriBuilder implementation used by Spring WebClient
问题
我使用以下语法使用get客户端进行get调用。在下面的示例中,使用了哪个URIBuilder实现,并且如何自动推断?
webclient.get().uri(uriBuilder -> uriBuilder.path("/api/person/{personId}")
.queryParam("param1", aDouble)
.queryParam("param2", "A string value with spaces")
.queryParam("param3", aListOfValues)
.queryParam("param4", null)
.build(anInteger))
这是我使用的webclient - WebClient
英文:
I use the below syntax to make a get call using get client. In the below example , which implementation of URIBuilder is being used and how is automatically inferenced?
webclient.get().uri(uriBuilder -> uriBuilder.path("/api/person/{personId}")
.queryParam("param1", aDouble)
.queryParam("param2", "A string value with spaces")
.queryParam("param3", aListOfValues)
.queryParam("param4", null)
.build(anInteger))
This is the webclient that I am using - WebClient
答案1
得分: 1
你可以在构建WebClient
时通过提供UriBuilderFactory
来决定使用哪种实现方式。
WebClient.Builder
有一个uriBuilderFactory(UriBuilderFactory)
方法,您可以在其中提供您的实现方式。
如果您没有提供实现方式,它目前会使用DefaultUriBuilderFactory
,该工厂会生成UriComponentsBuilder
实例。
<sub>您始终可以对您的代码进行调整,以打印出uriBuilder.getClass()
以进行确认。</sub>
英文:
You can decide which implementation is used WebClient
by providing a UriBuilderFactory
while building it.
The WebClient.Builder
has a uriBuilderFactory(UriBuilderFactory)
method where you can provide your implementation.
If you don't provide one, it currently uses DefaultUriBuilderFactory
which produces UriComponentsBuilder
instances.
<sub>You could always instrument your code to print uriBuilder.getClass()
for confirmation.</sub>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论