{title:'Interceptors', created:'8.2.0'}

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.

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();