Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 1.71 KB

File metadata and controls

62 lines (46 loc) · 1.71 KB

http-client-reactor-netty

This module provides to use Reactor Netty as reactive, non-blocking HTTP client implementation.

Install

Maven

<dependency>
    <groupId>com.github.ljtfreitas.julian-http-client</groupId>
    <artifactId>julian-http-client-http-client-reactor-netty</artifactId>
    <version>${julian-http-client-version}</version>
</dependency>

Gradle

dependencies {
    implementation("com.github.ljtfreitas.julian-http-client:julian-http-client-reactor-netty:$julianHttpClientVersion")
}

Usage

We need to configure the ProxyBuilder to use the implementation provided for this module:

import com.github.ljtfreitas.julian.http.client.reactor.ReactorNettyHTTPClient;

interface MyApi {}

ReactorNettyHTTPClient reactorNettyHTTPClient = new ReactorNettyHTTPClient();

MyApi myApi = new ProxyBuilder()
    .http()
        .client()
            .with(reactorNettyHTTPClient)
        .and()
    .build(MyApi.class, "http://my.api.com");

ReactorNettyHTTPClient uses a default HttpClient, but we can customize it:

import com.github.ljtfreitas.julian.http.client.reactor.ReactorNettyHTTPClient;
import reactor.netty.http.client.HttpClient;

interface MyApi {}

HttpClient httpClient = HttpClient
    .create()
    // other HttpClient options here...

ReactorNettyHTTPClient reactorNettyHTTPClient = new ReactorNettyHTTPClient(httpClient);

MyApi myApi = new ProxyBuilder()
    .http()
        .client()
            .with(reactorNettyHTTPClient)
        .and()
    .build(MyApi.class, "http://my.api.com");