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

ru.tinkoff.kora.http.client.common.HttpClient Maven / Gradle / Ivy

package ru.tinkoff.kora.http.client.common;

import ru.tinkoff.kora.common.Context;
import ru.tinkoff.kora.http.client.common.interceptor.HttpClientInterceptor;
import ru.tinkoff.kora.http.client.common.request.HttpClientRequest;
import ru.tinkoff.kora.http.client.common.response.HttpClientResponse;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

/**
 * Русский: Базовый интерфейс HTTP клиента для всех реализаций
 * 
* English: Basic HTTP client interface for all implementations */ public interface HttpClient { CompletionStage execute(HttpClientRequest request); default HttpClient with(HttpClientInterceptor interceptor) { return request -> { try { return interceptor.processRequest(Context.current(), (context, httpClientRequest) -> { var ctx = Context.current(); try { context.inject(); return this.execute(httpClientRequest); } finally { ctx.inject(); } }, request); } catch (Throwable e) { return CompletableFuture.failedFuture(e); } }; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy