davidcelis/api-pagination — pull request #21 by leods92 (2014-11-01 09:41:34+00:00)
Title: Added support to API proxies.

API Proxies are services that work in the middle between your clients and your API server.
They are useful for handling some API-exclusive logic so that you don't have to such as usage statistics, authentication, etc.
Some examples of API Proxies are: Apigee, 3scale and Mashery.

Current version of api-pagination generates links based on `request.url` but when we use a proxy that generate direct links to the API server which we don't want to expose (and which you probably made it unaccessible to outsiders anyway).

My approach to solve this problem was pretty simple: provide the option to generate relative links.
Relative links are allowed according to the Web Linking [RFC5988](http://tools.ietf.org/html/rfc5988#section-5.1).
So there's now an option `:relative_uri` which should be set to true if user so desires.

Another issue that I've stumbled upon was the base path.
Many APIs probably set a different domain such as `api.example.com` which makes all paths the same when using a proxy (unless you set something else in the proxy).
Other APIs though are nested in the main domain (e.g. `example.com/api`), maybe to be able to use SSL without new or expensive certificates.
That said, we should be able to hide such "/api" base path because from the client perspective (accessing through the proxy) that base path doesn't exist. More details in code comments.
I made that possible through the option `exclude_base_path`.

I've also added proper tests and they all pass.
This solution is already successfully being used in a production app of mine.

Hope this helps everyone.