Package kong.unirest.core
Class CompoundInterceptor
- java.lang.Object
-
- kong.unirest.core.CompoundInterceptor
-
- All Implemented Interfaces:
Interceptor
class CompoundInterceptor extends java.lang.Object implements Interceptor
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Interceptor>
interceptors
-
Constructor Summary
Constructors Constructor Description CompoundInterceptor()
CompoundInterceptor(java.util.List<Interceptor> interceptors)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.util.List<Interceptor>
getInterceptors()
HttpResponse<?>
onFail(java.lang.Exception e, HttpRequestSummary request, Config config)
Called in the case of a total failure.void
onRequest(HttpRequest<?> request, Config config)
Called just before a request.void
onResponse(HttpResponse<?> response, HttpRequestSummary request, Config config)
Called just after the request.(package private) void
register(Interceptor t1)
(package private) int
size()
-
-
-
Field Detail
-
interceptors
private java.util.List<Interceptor> interceptors
-
-
Constructor Detail
-
CompoundInterceptor
CompoundInterceptor()
-
CompoundInterceptor
CompoundInterceptor(java.util.List<Interceptor> interceptors)
-
-
Method Detail
-
onRequest
public void onRequest(HttpRequest<?> request, Config config)
Description copied from interface:Interceptor
Called just before a request. This can be used to view or modify the request. this could be used for things like - Logging the request - Injecting tracer headers - Record metrics The default implementation does nothing at all- Specified by:
onRequest
in interfaceInterceptor
- Parameters:
request
- the requestconfig
- the current configuration
-
onResponse
public void onResponse(HttpResponse<?> response, HttpRequestSummary request, Config config)
Description copied from interface:Interceptor
Called just after the request. This can be used to view the response, Perhaps for logging purposes or just because you're curious.- Specified by:
onResponse
in interfaceInterceptor
- Parameters:
response
- the responserequest
- a summary of the requestconfig
- the current configuration
-
onFail
public HttpResponse<?> onFail(java.lang.Exception e, HttpRequestSummary request, Config config) throws UnirestException
Description copied from interface:Interceptor
Called in the case of a total failure. This would be where Unirest was completely unable to make a request at all for reasons like: - DNS errors - Connection failure - Connection or Socket timeout - SSL/TLS errors The default implimentation simply wraps the exception in a UnirestException and throws it. It is possible to return a different response object from the original if you really didn't want to every throw exceptions. Keep in mind that this is a lie Nevertheless, you could return something like a kong.unirest.core.FailedResponse- Specified by:
onFail
in interfaceInterceptor
- Parameters:
e
- the exceptionrequest
- the original requestconfig
- the current config- Returns:
- a alternative response.
- Throws:
UnirestException
-
size
int size()
-
getInterceptors
java.util.List<Interceptor> getInterceptors()
-
register
void register(Interceptor t1)
-
-