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

reactivefeign.publisher.FluxPublisherHttpClient Maven / Gradle / Ivy

package reactivefeign.publisher;


import reactivefeign.client.ReactiveHttpClient;
import reactivefeign.client.ReactiveHttpRequest;
import reactivefeign.client.ReactiveHttpResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * Wraps {@link PublisherHttpClient}
 *
 * @author Sergii Karpenko
 */
public class FluxPublisherHttpClient implements PublisherHttpClient {

	private final ReactiveHttpClient reactiveHttpClient;

	public FluxPublisherHttpClient(ReactiveHttpClient reactiveHttpClient) {
		this.reactiveHttpClient = reactiveHttpClient;
	}

	@Override
	public Flux executeRequest(ReactiveHttpRequest request) {
		Mono response = Mono.defer(() -> reactiveHttpClient.executeRequest(request));
		return response.flatMapMany(ReactiveHttpResponse::body);
	}
}