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:
Rossen Stoyanchev
2019-12-12 20:56:03 +00:00
parent 802d083df7
commit 26a2d3875f
5 changed files with 60 additions and 24 deletions

View File

@@ -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>>#