I\'m using a spring-webflux WebClient (build 20170502.221452-172) to access a Web application producing a stream of Entry objects (application/stream+json) like th
You can configure this for a specific WebClient:
@Autowired
public ItunesAlbumServiceImpl(ObjectMapper mapper) {
ExchangeStrategies strategies = ExchangeStrategies.builder().codecs(clientCodecConfigurer ->
clientCodecConfigurer.customCodecs().decoder(
new Jackson2JsonDecoder(mapper,
new MimeType("text", "javascript", StandardCharsets.UTF_8)))
).build();
webClient = WebClient.builder()
.exchangeStrategies(strategies)
.baseUrl("https://itunes.apple.com")
.build();
}
But also on 'application level'
by configuring a CodecCustomizer:
@Bean
public CodecCustomizer jacksonLegacyJsonCustomizer(ObjectMapper mapper) {
return (configurer) -> {
MimeType textJavascript = new MimeType("text", "javascript", StandardCharsets.UTF_8);
CodecConfigurer.CustomCodecs customCodecs = configurer.customCodecs();
customCodecs.decoder(
new Jackson2JsonDecoder(mapper, textJavascript));
customCodecs.encoder(
new Jackson2JsonEncoder(mapper, textJavascript));
};
}
which will be made effective by the WebClientAutoConfiguration as a WebClient.Builder bean:
@Autowired
public ItunesAlbumServiceImpl(WebClient.Builder webclientBuilder) {
webClient = webclientBuilder.baseUrl("https://itunes.apple.com").build();
}