Skip to content

Instantly share code, notes, and snippets.

@Sutto
Created March 13, 2012 05:42
Show Gist options
  • Save Sutto/2027037 to your computer and use it in GitHub Desktop.
Save Sutto/2027037 to your computer and use it in GitHub Desktop.
in response to http://twitter.com/#!/sj26/status/179435393622605825 - Namely, did I consider using Headers on the response.
Now, I didn't consider them in depth but I did consider them a little. Most of the reasons to use them were pragmatic in nature
(following a possibly flawed thought pattern):
- I felt that those details about the data are part of the data itself - versus extra metadata about the resource in general.
- Collections still ideally to be under an object (versus an array) for security reasons - http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx
- In doing so, it makes sense that if you're going to put the data inside a nested object, ideally you should place the data there as well for consistency.
- It makes the style of clients slightly easier because JSON conveys type information not necessarily present in headers.
- Unicorns.
With all of that said and done, one of the items on the cards for rocket pants is the ability to flip that around - Basically, the idea of presenters in the regards they handle setting the metadata on the request. The usefulness then being it's easier to do things like https://en.wikipedia.org/wiki/HATEOAS without having to manually override stuff. Likewise, things like switching the way versioning is handled should be optionated but easy to switch out if you disagree.
@sj26
Copy link

sj26 commented Mar 13, 2012

Another good argument Greg just proposed, putting metadata in the headers means you can HEAD for the metadata, potentially just the pagination links to skip around the result set without downloading everything.

@Sutto
Copy link
Author

Sutto commented Mar 17, 2012

I think I'd argue that it goes against discoverability, but the benefits I think are def. worth making it one of the default options. I'll have a look into it. I'm also planning on taking some of the design ideas from Designing Hypermedia APIs into consideration for the next major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment