{8.2.0-new} Interceptors

The {@link oajr.client2.RestCallInterceptor} API provides a quick way of intercepting and manipulating requests and responses beyond the existing {@link org.apache.http.protocol.HttpRequestInterceptor} and {@link org.apache.http.protocol.HttpResponseInterceptor} APIs.

- {@link oajr.client2.RestClientBuilder}
  - {@link oajr.client2.RestClientBuilder#interceptors(Object...) interceptors(Object...)}
- {@link oajr.client2.RestRequest}
  - {@link oajr.client2.RestRequest#interceptors(RestCallInterceptor...) interceptors(RestCallInterceptor...)}
- {@link oajr.client2.RestCallInterceptor}
  - {@link oajr.client2.RestCallInterceptor#onInit(RestRequest) onInit(RestRequest)}
  - {@link oajr.client2.RestCallInterceptor#onConnect(RestRequest,RestResponse) onConnect(RestRequest,RestResponse)}
  - {@link oajr.client2.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();