Skip to content

gh-298 Add a per-client request factory customizer#300

Open
SlobodianBohdan wants to merge 6 commits into
ch4mpy:masterfrom
SlobodianBohdan:gh-298-customizer
Open

gh-298 Add a per-client request factory customizer#300
SlobodianBohdan wants to merge 6 commits into
ch4mpy:masterfrom
SlobodianBohdan:gh-298-customizer

Conversation

@SlobodianBohdan

Copy link
Copy Markdown

Part of #298. Stacked on top of #299 — please merge #299 first; this PR will then be
rebased onto master to leave only the customizer commit. (Until then it shows #299's
commits too.)

Adds a per-client request factory customizer, for configuration that is not exposed as
properties.

  • New HttpClientCustomizer<B> functional interface — a single generic interface where B
    is the implementation-specific builder of the configured client-http-request-factory-impl:
    java.net.http.HttpClient.Builder (jdk), org.apache.hc.client5.http.impl.classic.HttpClientBuilder
    (http-components) or org.eclipse.jetty.client.HttpClient (jetty).

  • New per-client request-factory-customizer-bean property naming the bean to apply.

  • The bean is resolved from the ApplicationContext and applied to the underlying client
    builder just before the request factory is built, in each implementation's helper.

    Example:

    com:
    c4-soft:
    springaddons:
    rest:
    client:
    machin-client:
    http:
    request-factory-customizer-bean: machinHttpClientCustomizer

    @bean
    HttpClientCustomizer<HttpClient.Builder> machinHttpClientCustomizer() {
    return builder -> builder.version(HttpClient.Version.HTTP_1_1);
    }

README updated with a dedicated section; tests included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant