{8.2.0-new} Extending RestClient

The RestClient API has been designed to allow for the ability to be easily extended. The following example that overrides the primary run method shows how this can be done.

Example:

public class MyRestClient extends RestClient { // Must provide this constructor! public MyRestClient(PropertyStore ps) { super(ps); } @Override public HttpResponse run(HttpHost target, HttpRequest request, HttpContext context) throws IOException { // Perform special handling of requests. } } // Instantiate your client. MyRestClient client = RestClient.create().json().build(MyRestClient.class);

The {@link oajr.client2.RestRequest} and {@link oajr.client2.RestResponse} objects can also be extended and integrated by overriding the {@link oajr.client2.RestClient#createRequest(URI, String, boolean)} and {@link oajr.client2.RestClient#createResponse(RestRequest, HttpResponse, Parser)} methods.