-
Notifications
You must be signed in to change notification settings - Fork 1
rest
Christopher P. Brown edited this page Jul 27, 2023
·
4 revisions
Representational State Transfer
invented by some dude named Roy in y2k for his doctoral thesis
a pattern for creating RESTful web services
HTTP Method | CRUD | Collection | Item |
---|---|---|---|
POST | Create | 201 (Created), ‘Location’ header withlink to /users/{id} containing new ID. | Avoid using POST on single resource |
GET | Read | 200 (OK), list of users. Use pagination, sorting and filtering to navigate big lists. | 200 (OK), single user. 404 (Not Found), if ID not found or invalid. |
PUT | Update/Replace | 405 (Method not allowed), unless you want to update every resource in the entire collection of resource. | 200 (OK) or 204 (No Content). Use 404 (Not Found), if ID not found or invalid. |
PATCH | Partial Update/Modify | 405 (Method not allowed), unless you want to modify the collection itself. | 200 (OK) or 204 (No Content). Use 404 (Not Found), if ID not found or invalid. |
DELETE | Delete | 405 (Method not allowed), unless you want to delete the whole collection — use with caution. | 200 (OK). 404 (Not Found), if ID not found or invalid. |
RESTful APIs must be Hypertext Driven. This is the concept of Hypermedia As The Engine Of Application State (HATEOAS)
https://htmx.org/essays/how-did-rest-come-to-mean-the-opposite-of-rest/
https://hypermedia.systems/book/contents/
Most modern JSON API responses are not RESTful but instead resemble Remote Procedure Calls (RPC)
- SOAP
- RPC