Comments (4)
The principle Nouns are good, verbs are bad doesn't mean that verbs can never be used. In some cases there are no natural ways to treat an action as a CRUD operation on a resource.
https://blog.apigee.com/detail/restful_api_design_tips_for_search
from restcookbook.
I agree with @SIOUF, the HATEOAS example is really misleading. In REST APIs all URLs must point to resources. If you have URLs that represent actions, then you are doing RPC (remote procedure call), which is a valid approach to implementing an API, but it is not REST.
A RESTful representation for your Account resources would offer the following links:
<link rel="deposit" href="/account/12345/deposits" />
<link rel="withdraw" href="/account/12345/withdrawals" />
<link rel="transfer" href="/account/12345/transfers" />
Sending a GET request to any of these returns transactions of that type. Sending a POST request creates a new transaction of the given type. PUT modifies a transaction, and DELETE (if allowed) deletes a transaction. To close an account you would not have a resource, you would either send a PUT request to the account resource and modify a state
from open to closed, or else you can also send a DELETE request to the account resource.
The second part of the article, where a new resource representation is shown as having less links due to the account being in red is also incorrect. The links always exist and are always available, regardless of the account balance. If you send a POST request to the /withdrawals
request and the account is in red, then the request will simply fail, maybe with a 403 (Forbidden).
from restcookbook.
Yes, i must agree with this, and it should be changed. I can make the changes, but due to lack of current time this might take a while. A pull-request with some updated info would be really helpful at the moment.
from restcookbook.
Okay, I'll see if I can come up with something in the next couple of days.
from restcookbook.
Related Issues (19)
- twitter bootstrap HOT 3
- PATCH requires a diff media type HOT 7
- Site Link HOT 1
- Change examples to full details
- Downloadable epub ebook HOT 4
- Code-on-demand HOT 4
- Will u a add a license to the book? HOT 2
- Isn't PATCH idempotent? HOT 1
- no links HATEOAS on Richardson Maturity Model page
- "fork me on github" is not accessible HOT 1
- Incorrect capitalization of Content-Type header HOT 1
- the use of the Location header with HTTP 202 is not actually supported
- Please clarify the license of restcookbook
- Possible mistake in put-vs-post
- HTTPS cert on your website HOT 3
- Links on the home page not working correctly. HOT 5
- PATCH is said to be and not be idempotent HOT 3
- OAuth2 is not draft anymore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from restcookbook.