Bowery/orchestrate.js — pull request #28 by housejester (2014-03-22 17:32:35+00:00)
Title: Parse links from the response header.

I took a stab at implementing what I'd mentioned in the comments (ie only do link parsing when it makes sense, and don't put the function on the response.body object). I would up being able to generalize it pretty well so that whenever new links are added on the orchestrate side, the client will pick it up and make it available. This is leveraging the Link response header that orchestrate uses to expose the pagination links (the same 'next' link in the json payload is also in the header).

Anyway, let me know what you think.
-----
This changes the 'next' link parsing logic to parse links from the
response header instead of the response json. This makes it so that
any new links that Orchestrate eventually adds (ie 'prev') will
be automatically picked up by the client. Also, as pagination is
added to other parts of orchestrate (events, graph, etc), the client
also picks it up automatically.

Any links found in the 'Link' header on any 'GET' request will be
parsed out and made available on the response object under
response.links. Each link will have various properties (url, rel,
params, etc) as well as a 'get' function to fetch the url that
returns a promise.