Re:The RESTful CookBook
by barkmadley on Monday April 01, 2013 @07:41AM
(#5472457)
If I may, the goal seems a bit incorrectly specified for hypermedia. For instance, if github decided to change the number of results they return per page, then your script would not break, but it would have a different meaning.
I would suggest a better goal to be "get the 11th public gist". Although that still isn't perfect since it doesn't mention how the collection would be sorted (I presume by date).
Re:The RESTful CookBook
by steveklabnik on Monday April 01, 2013 @01:38PM
(#5474579)
Absolutely, this goal is bad. I was just trying to show off the mechanics, and that clients don't have to be complex.
Yes, you can write clients for GitHub's API that works that way, for example.
Here, I whipped you up one: https://gist.github.com/steveklabnik/5282209/e48b100d95ff77f...
This client will return you information about the first gist on the second page of the public list. It does this by fetching the list of gists from the root, then using the pagination to walk forward. GitHub can change all of this, and it'll still work.
Bonus: here's a slightly refactored version. The logic is more clear when you move things into helpers. https://gist.github.com/steveklabnik/5282209/52ed62366586838...