Live data from Hacker News

How I learned to stop worrying and love REST

mikemayo.org

31–38 of 38 posts

Re: How I learned to stop worrying and love REST

#31
post #2

Disclaimer: I do not want to steal the author's page views, but I could hardly read this article, due to the white shadow in the Text. Here is a more readable view: http://rdit.in/5c

I suggest you try out Evernote Clearly http://www.evernote.com/clearly/ . It comes with a browser extension, using which you can convert a blurb of text that is difficult to read into an easily readable one.

Thanks for the suggestion. There are others as well: http://www.readability.com/bookmarklets http://www.instapaper.com/m

Clear Read is my own take on this though.

Re: How I learned to stop worrying and love REST

#32
post #27

What is the HATEOS compliant way of accepting parameters? E.g. for the pagination example, you might want to let the consumer specify number of entries pr. page, or you might want to accept a search-term or limit by period.

There is actually a HTTP header (Range) that can be used for this. Works well in APIs but you can't do it with browsers, which is unfortunate.

Can you not set custom headers in browsers?

Re: How I learned to stop worrying and love REST

#33

This is probably my number one criticism of most "REST" APIs out there - they are horribly non self-documenting, and the effort required to make them self-documenting is really fairly trivial: 1. Ensure that you have a URI to the resource in question every single time you reference an ID somewhere (in collections, when referencing resources from another resource) 2. Make the root of your application document all the…

Yea, This is exactly what I do and it makes writing rest clients a breeze!

eg http://pastie.org/3326375

Re: How I learned to stop worrying and love REST

#34
post #21

Earlier quoted context omitted.

I find URL templates smelly. Once you stick a place holder in the URL, it's no longer a valid URL - it's something that requires custom mangling before it can be passed along. In your example, I need to know that the x is something that requires replacement. How is that fundamentally different from just putting in your documentation (and, in the 405 if not passed) "this resources takes query param baz" - which is not…

> I find URL templates smelly. Once you stick a place holder in the URL, it's no longer a valid URL - it's something that requires custom mangling before it can be passed along. This is why a standard has been drafted for this particular problem, the mangling becomes standard and predictable rather than customized to each use case. http://tools.ietf.org/html/draft-gregorio-uritemplate-08

Ooo - Very interesting, I've been looking for something like this.

I even wrote my own version of this a while back, and scrapped it due to the complexity. A standard would allow for the complexity to be wrapped away in a library :)

Re: How I learned to stop worrying and love REST

#35
post #27

Earlier quoted context omitted.

There is actually a HTTP header (Range) that can be used for this. Works well in APIs but you can't do it with browsers, which is unfortunate.

Can you not set custom headers in browsers?

You can do it with AJAX requests, but not with links or regular forms (as far as I am aware... I'd love to hear otherwise)

Re: How I learned to stop worrying and love REST

#36
post #35

Earlier quoted context omitted.

Can you not set custom headers in browsers?

You can do it with AJAX requests, but not with links or regular forms (as far as I am aware... I'd love to hear otherwise)

Should a REST API ever be expose by a form or link?

Re: How I learned to stop worrying and love REST

#37
i'm suprised using something like mod_rewrite to transform the query parameters into something that rails could cache was not mentioned. it's a cheap way to use the url structure you want after the fact. the next update the app can then use the new structure and the mod_rewrite rules will be there to support the old api until almost everyone has upgraded to the new app. this allows one to switch an api to being more restful in a graceful way.

Re: How I learned to stop worrying and love REST

#38
post #35

Earlier quoted context omitted.

You can do it with AJAX requests, but not with links or regular forms (as far as I am aware... I'd love to hear otherwise)

Should a REST API ever be expose by a form or link?

The web is basically a REST API, no? (I'm being a bit facetious.)
Post reply on HN