Interface Methanol.Interceptor
- All Known Implementing Classes:
CacheInterceptor, RedirectingInterceptor, RetryInterceptor
- Enclosing class:
Methanol
public static interface Methanol.Interceptor
An object that intercepts requests before being sent and responses before being returned.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn object that gives interceptors the ability to relay requests to sibling interceptors, till eventually being sent by the client's backend. -
Method Summary
Modifier and TypeMethodDescriptionstatic Methanol.Interceptorcreate(Function<HttpRequest, HttpRequest> operator) Returns an interceptor that forwards the request after applying the given operator.<T> HttpResponse<T> intercept(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Intercepts given request and returns the resulting response, usually by forwarding to the given chain.<T> CompletableFuture<HttpResponse<T>> interceptAsync(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Intercepts the given request and returns aCompletableFuturefor the resulting response, usually by forwarding to the given chain.
-
Method Details
-
intercept
<T> HttpResponse<T> intercept(HttpRequest request, Methanol.Interceptor.Chain<T> chain) throws IOException, InterruptedException Intercepts given request and returns the resulting response, usually by forwarding to the given chain.- Throws:
IOExceptionInterruptedException
-
interceptAsync
<T> CompletableFuture<HttpResponse<T>> interceptAsync(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Intercepts the given request and returns aCompletableFuturefor the resulting response, usually by forwarding to the given chain. -
create
Returns an interceptor that forwards the request after applying the given operator.
-