Add apply method to WebClient.Builder
This commit introduces an apply method to `WebClient.Builder`, allowing users to make multiple changes to the builder in one consumer. Issue: SPR-15743
This commit is contained in:
@@ -157,6 +157,19 @@ public class DefaultWebClientTests {
|
||||
client.get().uri("/path").attribute("foo", "bar").exchange();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void apply() {
|
||||
WebClient client = builder()
|
||||
.apply(builder -> builder.defaultHeader("Accept", "application/json").defaultCookie("id", "123"))
|
||||
.build();
|
||||
client.get().uri("/path").exchange();
|
||||
|
||||
ClientRequest request = verifyExchange();
|
||||
assertEquals("application/json", request.headers().getFirst("Accept"));
|
||||
assertEquals("123", request.cookies().getFirst("id"));
|
||||
verifyNoMoreInteractions(this.exchangeFunction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private WebClient.Builder builder() {
|
||||
|
||||
Reference in New Issue
Block a user