All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.danielliu1123.httpexchange.HttpClientCustomizer Maven / Gradle / Ivy

There is a newer version: 3.4.1
Show newest version
package io.github.danielliu1123.httpexchange;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;

/**
 * {@link HttpClientCustomizer} customizes the configuration of the http client based on the given {@link HttpExchangeProperties.Channel}.
 *
 * @author Freeman
 * @see ExchangeClientCreator#buildRestClient(HttpExchangeProperties.Channel)
 * @see ExchangeClientCreator#buildRestTemplate(HttpExchangeProperties.Channel)
 * @see ExchangeClientCreator#buildWebClient(HttpExchangeProperties.Channel)
 * @since 3.2.4
 */
public sealed interface HttpClientCustomizer {

    /**
     * Customize the client builder with the given config.
     *
     * @param client the http client to customize
     * @param channel the current channel config to use
     */
    void customize(T client, HttpExchangeProperties.Channel channel);

    non-sealed interface RestClientCustomizer extends HttpClientCustomizer {}

    /**
     * Use {@link RestTemplate} instead of {@link RestTemplateBuilder} because the latter is immutable.
     */
    non-sealed interface RestTemplateCustomizer extends HttpClientCustomizer {}

    non-sealed interface WebClientCustomizer extends HttpClientCustomizer {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy