Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.