TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

REST Anti-Patterns (2008)

174 pointsby xparadigmabout 8 years ago

11 comments

strictneinabout 8 years ago
&gt; Ignoring status codes<p>My favorite is when everything returns a 200, but the response is something like:<p><pre><code> { status: &quot;fail&quot;, error: &quot;forbidden&quot; } </code></pre> Sometimes they even include the 403 in the response, almost like the developer is giving you a giant middle finger.
评论 #14310037 未加载
评论 #14310318 未加载
评论 #14313420 未加载
评论 #14310794 未加载
评论 #14312286 未加载
评论 #14310676 未加载
评论 #14310279 未加载
评论 #14310489 未加载
评论 #14310335 未加载
评论 #14311090 未加载
评论 #14310594 未加载
评论 #14309994 未加载
kbutlerabout 8 years ago
The problem is that people want an RPC mechanism, and REST gives them a document transfer mechanism.<p>If your API will never be navigated by a human operating a browser, a lot of the REST specification is inapplicable (navigation links, etc.)<p>So you&#x27;re throwing out a lot of REST regardless, and the question becomes where to draw the line between ease of implementation and compliance with a standard that doesn&#x27;t really fit your needs.
评论 #14310975 未加载
评论 #14312006 未加载
评论 #14313083 未加载
daliwaliabout 8 years ago
The biggest anti-pattern of all: marketing your API as RESTful, when it is really more RPC-like.<p>I agree on all points of this article. The only nitpick I have is that tunneling through GET&#x2F;POST is strictly necessary for HTML forms, since they do not support other verbs.
评论 #14314089 未加载
dicroceabout 8 years ago
If API&#x27;s are best represented via REST, then why aren&#x27;t software API&#x27;s in general RESTful (e.g. I dont POST triangles to my GPU)? The answer: SOME API&#x27;s are best represented with REST, but most are not.
评论 #14310163 未加载
sopooneoabout 8 years ago
I believe REST as Fielding defined it has some great benefits. But I&#x27;m not a purist. And actually, neither is the person who wrote this post. Because no matter how much the disciples try to wriggle there way around it, using cookies for sessions is not allowed.<p>&quot;We next add a constraint to the client-server interaction: communication must be stateless in nature, as in the client-stateless-server (CSS) style of Section 3.4.3 (Figure 5-3), such that each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server.Session state is therefore kept entirely on the client.&quot; - from Fieldings dissertation.<p>To be fully compliant you have to do use something like HTTP Basic Auth, where you resend the username and password with each request.<p>I think you should use cookies to store a token that the server can then use to determine whether the &quot;context&quot; of the request is &quot;logged in&quot; or not. I do it. But it&#x27;s technically a violation.
评论 #14314052 未加载
评论 #14314544 未加载
marichardsabout 8 years ago
Missing anti pattern: consider URLs insecure, especially if for a web browser. Don&#x27;t include customer details (name, email, account number, etc) or search queries (free text) unless you have determined the security settings on your logging, audit, proxies, .., all conform to data protection requirements that suggest they should be encrypted and only visible to necessary staff. If you expect pages to be bookmarked or shared, then consider the security impact of where they are stored on local machines too, including in caches if your company is silly enough not to enforce disk encryption for all users.
评论 #14310352 未加载
评论 #14310092 未加载
yeukhonabout 8 years ago
My #1 complaint is there is no OOP client available from service provider. i.e. building a driver to consume the response and turn that into your client code. The irony is I often write my own harness for REST service, and those are generally object-oriented, because I don&#x27;t want to speak HTTP over and over. Basically I built my a client while writing test, but I need to write test to assert my client which was developed to help writing my test.
评论 #14310599 未加载
lloydjatkinsonabout 8 years ago
Anti-pattern #1: Using REST. It&#x27;s just cargo cult along with everyone describing it and then implementing it differently. The only good part it has is how to layout the URL, and even then it&#x27;s just common sense.
评论 #14324676 未加载
jaequeryabout 8 years ago
seriously i dont really care whether an api is restful or restish. at the end of the day its all the same to me. just give me an api endpoint, request and response objects nicely documented and i am golden.
throwaway18917about 8 years ago
Have we considered that these REST &quot;anti-patterns&quot; exist because REST is fundamentally inappropriate for what most people are trying to use it for? What if you can&#x27;t shoehorn your functionality into the handful of REST verbs? What if none of the status codes make sense?<p>What ever happened to plain old RPC? Have we stopped to consider that people tunnel things through POST or GET requests because it&#x27;s easier and more flexible than trying to cram your functionality into GET, POST, PUT, PATCH, or DELETE?<p>If you find yourself using a lot of these anti-patterns, maybe you should consider switching to something a little less &quot;REST-ful&quot;.
评论 #14310200 未加载
评论 #14312887 未加载
评论 #14309825 未加载
评论 #14309841 未加载
评论 #14311304 未加载
评论 #14309689 未加载
评论 #14313592 未加载
评论 #14310571 未加载
评论 #14311281 未加载
评论 #14309996 未加载
dangabout 8 years ago
Same title, different article from a few months ago: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12479370" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12479370</a>.
评论 #14310632 未加载