HTTP/1.1 201 Created Content-Length: 438 Content-Type: application/json Link: </profile>; rel="profile" Location: "/" {"message":"you are being redirected"} Wednesday, October 17, 12
Content-Type: text/plain This server emits "microblogging JSON." ## Keys You can expect the following keys: statuses, template, links ## Link Relations You can expect a "collection" relation. GETing the URI will fetch the list of all statuses. POSTing a template to this URI will create a new status. Wednesday, October 17, 12
It is important to follow these Link header values instead of constructing your own URLs. In some instances, such as in the Commits API, pagination is based on SHA1 and not on page number. Link: <https://api.github.com/user/repos? page=3&per_page=100>; rel="next", <https://api.github.com/user/repos? page=50&per_page=100>; rel="last" Wednesday, October 17, 12
@body = opts['body'] @location = opts['location'] @self_rel = opts['links'].find{|link| link['rel'] == "self"}['href'] end def location @location ||= begin fetch_data(self_rel)['location'] end end end Wednesday, October 17, 12