Expose ClientCodecConfigurer in WebClient.Builder
Using Consumer<ClientCodecConfigurer> instead of
Consumer<ExchangeStrategies> eliminates one level of nesting that is
also unnecessary since codecs are the only strategy at present.
Backport of dd9b6287b4
Closes gh-24201
This commit is contained in:
@@ -908,20 +908,16 @@ The following example shows how to do so for client-side requests:
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
Consumer<ClientCodecConfigurer> consumer = configurer -> {
|
||||
CustomDecoder customDecoder = new CustomDecoder();
|
||||
configurer.customCodecs().decoder(customDecoder);
|
||||
configurer.customCodecs().withDefaultCodecConfig(config ->
|
||||
customDecoder.maxInMemorySize(config.maxInMemorySize())
|
||||
);
|
||||
}
|
||||
|
||||
WebClient webClient = WebClient.builder()
|
||||
.exchangeStrategies(strategies -> strategies.codecs(consumer))
|
||||
.codecs(configurer -> {
|
||||
CustomDecoder decoder = new CustomDecoder();
|
||||
configurer.customCodecs().registerWithDefaultConfig(decoder);
|
||||
})
|
||||
.build();
|
||||
----
|
||||
====
|
||||
|
||||
|
||||
[[webflux-dispatcher-handler]]
|
||||
== `DispatcherHandler`
|
||||
[.small]#<<web.adoc#mvc-servlet, Same as in Spring MVC>>#
|
||||
|
||||
Reference in New Issue
Block a user