Skip to content

Auto-configure WebClient #8630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philwebb opened this issue Mar 15, 2017 · 4 comments
Closed

Auto-configure WebClient #8630

philwebb opened this issue Mar 15, 2017 · 4 comments
Assignees
Labels
status: duplicate A duplicate of another issue type: enhancement A general enhancement

Comments

@philwebb
Copy link
Member

We need a WebClient story to replace RestTemplate in the reactive world.

@snicoll
Copy link
Member

snicoll commented Mar 15, 2017

I gave some thoughts to that one. If we want to make things consistent, we probably need a WebClientBuilder that takes the converters and other things Spring Boot may auto-configure in the future. It is then a matter of updating @AutoconfigureWebClient.

I don't think we have custom converters support at the moment. When is that scheduled @bclozel ?

@bclozel
Copy link
Member

bclozel commented Mar 15, 2017

WebClientBuilder is probably the best choice here.
Now about converters, we're in the process or reworking that bit in Framework, since we noticed that sharing an ObjectMapper instance between encoders/decoders can involve a lot of configuration. We should probably wait for SPR-15247 to be fixed before we start writing code in the message encoders/decoders auto-configuration, for both client and server.

@joshiste
Copy link
Contributor

Please also take the WebTestClient into account.

I expected, that the WebTestClient uses the autoconfigured ObjectMapper from the application context, but it doesn't.

Currently adding a new Jackson module to the WebTestClient is a bit tedious and renders the preconfigured WebTestClient useless.

my current solution:

    @Autowired
    private ObjectMapper mapper;

  ...

        webClient = WebTestClient.bindToServer()
                                 .baseUrl("http://localhost:" + port)
                                 .exchangeStrategies(ExchangeStrategies.builder().defaultCodecs((configurer) -> {
                                     configurer.jackson2Decoder(new Jackson2JsonDecoder(mapper));
                                     configurer.jackson2Encoder(new Jackson2JsonEncoder(mapper));
                                 }).build())
                                 .build();

@bclozel bclozel self-assigned this Jun 12, 2017
@bclozel
Copy link
Member

bclozel commented Jul 25, 2017

Oops - I think this one is duplicates by #9577 and #9522 - those are already solved and documented.

@bclozel bclozel closed this as completed Jul 25, 2017
@bclozel bclozel added the status: duplicate A duplicate of another issue label Jul 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants