The {@link oajrc.RestCallInterceptor} API provides a quick way of intercepting and manipulating requests and responses beyond
the existing {@link org.apache.http.HttpRequestInterceptor} and {@link org.apache.http.HttpResponseInterceptor} APIs.
- {@link oajrc.RestClient.Builder}
- {@link oajrc.RestClient.Builder#interceptors(Object...) interceptors(Object...)}
- {@link oajrc.RestRequest}
- {@link oajrc.RestRequest#interceptors(RestCallInterceptor...) interceptors(RestCallInterceptor...)}
- {@link oajrc.RestCallInterceptor}
- {@link oajrc.RestCallInterceptor#onInit(RestRequest) onInit(RestRequest)}
- {@link oajrc.RestCallInterceptor#onConnect(RestRequest,RestResponse) onConnect(RestRequest,RestResponse)}
- {@link oajrc.RestCallInterceptor#onClose(RestRequest,RestResponse) onClose(RestRequest,RestResponse)}
Example:
| // Create a client with a customized interceptor.
| RestClient client = RestClient
| .create()
| .interceptors(
| new RestCallInterceptor() {
|
| @Override
| public void onInit(RestRequest req) throws Exception {
| // Intercept immediately after RestRequest object is created and all headers/query/form-data has been
| // set on the request from the client.
| }
|
| @Override
| public void onConnect(RestRequest req, RestResponse res) throws Exception {
| // Intercept immediately after an HTTP response has been received.
| }
|
| @Override
| public void onClose(RestRequest req, RestResponse res) throws Exception {
| // Intercept when the response body is consumed.
| }
| }
| )
| .build();