TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Nobody Understands REST or HTTP

100 点作者 shinvee超过 13 年前

11 条评论

DanielRibeiro超过 13 年前
This was posted 7 months ago on HN (with 510 points!): <a href="http://news.ycombinator.com/item?id=2724488" rel="nofollow">http://news.ycombinator.com/item?id=2724488</a><p>Very lengthy discussion at that time.
评论 #3636423 未加载
Argorak超过 13 年前
The part about "accept-language" doesn't address the real problem. If I copy the url to a piece of content that is available in 2 languages and send it to someone else, I want them to read it in the same language as I originally read it. Sadly, I cannot copy Accept-Headers in a fashion that "normal" people understand. To me, resources written in 2 different languages may be instances of the same thing, but not the same resource.<p>At worst, the page in question uses automatic translation (not so uncommon when it comes to large knowledge bases), so the translation might be odd.<p>Basically, according to the article, Wikipedia has it all wrong.
评论 #3635426 未加载
richardlblair超过 13 年前
There are numerous opinions on the subject of RESTful apis. The author of this post makes many good points, but I, like many of you disagree with his opinion on versioning.<p>While putting the version into the header is clever, it reduces the usability of your api. When you are designing a RESTful api you typically want to design your api so that it is simple and easy to implement. Nothing is easier than being able to explore an api via a web browser. If you make the user specify versions in the header than they will have to install a browser plugin to explore your api.<p>You have to consider that you aren't always "selling" to other developers who understand http headers. You could be "selling" to non technical project managers and CEOs who simply don't understand http headers. They do understand URIs, though. So if you can provide these people with a URI that just works, and they can poke around and see data they have a greater chance of understanding and getting excited about your API.
StavrosK超过 13 年前
This says versioning in the URI is wrong. Why? I much prefer separating my API versions into different files at the dispatcher level. Doing it with the header would be a mess in most frameworks, and I don't see what it hurts.<p>Also, what about custom HTTP verbs? Many times I need something more than GET/PUT/POST/DELETE. What happens then? I haven't seen anyone talk about that.
评论 #3635423 未加载
评论 #3635347 未加载
评论 #3635986 未加载
评论 #3636085 未加载
评论 #3635457 未加载
评论 #3636538 未加载
tzaman超过 13 年前
Interesting. But it has one flaw; how exactly would I do this<p>curl <a href="https://api.twilio.com/2010-04-01/Accounts" rel="nofollow">https://api.twilio.com/2010-04-01/Accounts</a> -H "Accept: application/json<p>inside a browser on a normal GET request?
评论 #3635446 未加载
评论 #3636802 未加载
评论 #3635447 未加载
hcarvalhoalves超过 13 年前
A lot of good points there, but the part about detecting mobile devices is a bit short sighted.<p>Varying your content based on mobile User-Agent (or any User-Agent actually) renders public caches almost impossible to get right.
评论 #3636693 未加载
thomasbachem超过 13 年前
Thanks so much for saying what needed to be said :)!<p>David Zülke has a very good talk about REST that he's holding at conferences around the world regularly: <a href="http://www.slideshare.net/Wombert/designing-http-interfaces-and-restful-web-services-phpday11-20110514" rel="nofollow">http://www.slideshare.net/Wombert/designing-http-interfaces-...</a>.
评论 #3637063 未加载
___Calv_Dee___超过 13 年前
This webinar by Brian Mulloy is a nice complement to the post and offers up some great design tips when it comes to designing a RESTful API...<p><a href="http://blog.apigee.com/detail/slides_for_restful_api_design_second_edition_webinar/" rel="nofollow">http://blog.apigee.com/detail/slides_for_restful_api_design_...</a>
LewisCr超过 13 年前
For more resources on this topic, I have been leafing through O'Reilly's Hypermedia APIs book, it's been interesting.
评论 #3638644 未加载
latch超过 13 年前
He didn't go over the common example of paging by including<p><pre><code> nav { prev: '...', next: '....'} </code></pre> in the response. But, the thing that always concerns me about this is that it requires the client to maintain state. If you consume such a web service in a web app, and the user hits "next", you'll have to have stored the next url somewhere.
评论 #3635556 未加载
评论 #3635616 未加载
javascriptlol超过 13 年前
If I want to raise my blood pressure into the 180's all I have to do is open a thread about web design "principles".<p>He has the perfect anti-example for HATEOAS right in there: financial transactions. You would never in 1 million years want to discover the API for such a thing by experimentation, because there are specific precision requirements.<p>Every time someone tries to explain the benefits of this nonsense to me it's either 1) something you could already do with sockets 20+ years ago, or 2) a poorly motivated academic idea that doesn't get me closer to implementing a correct system with good documentation.