Robopupu.REST API

Robopupu.REST API is a minimal and very light-weight API to define and use REST request. It is basically networking library agnostic, but currently I use it with Google Volley. Currently, I have not experimented using the REST API with OkHttp3 – the other networking library I have been using.

Using Google Volley

The key class for using Robopupu.REST API with Volley is the RequestSpec. It  provides a builder API for specifying requests based on Volley’s Request class. The builder API provides convenience methods for specifying base url, relative url, query params, paths params, headers, retry policy, timeout, encoding, and the utilised Volley Request object. Here is an example of simple request specified by using the RequestSpec class:


final Context context = ...;
final RequestSpec<JokeResponse> getJoke 
    = new RequestSpec<JokeResponse>(context, "http://api.icndb.com/jokes/random").
         request(new GsonRequest<>(JokeResponse.class));