You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1574,3 +1574,30 @@ HTTP APIs following **REST** tend to be used more often for public APIs.
1574
1574
* A new API must be definied for every new operation or use case.
1575
1575
* It can be difficult to debug RPC.
1576
1576
* You might not be able to leverage existing technologies out of the box. For example, it might require additional effort to ensure [RPC calls are properly cached](http://etherealbits.com/2012/12/debunking-the-myths-of-rpc-rest/) on caching servers such as [Squid](http://www.squid-cache.org/).
1577
+
1578
+
### Representational state transfer (REST)
1579
+
1580
+
REST is an architectural style enforcing a client/server model where the client acts on a set of resources managed by the server. The server provides a representation of resources and actions that can either manipulate or get a new representation of resources. All communication must be stateless and cacheable.
1581
+
1582
+
There are four qualities of a RESTful interface:
1583
+
1584
+
***Identify resources (URI in HTTP)** - use the same URI regardless of any operation.
1585
+
***Change with representations (Verbs in HTTP)** - use verbs, headers, and body.
1586
+
***Self-descriptive error message (status response in HTTP)** - Use status codes, don't reinvent the wheel.
1587
+
***[HATEOAS](http://restcookbook.com/Basics/hateoas/) (HTML interface for HTTP)** - your web service should be fully accessible in a browser.
1588
+
1589
+
Sample REST calls:
1590
+
1591
+
```
1592
+
GET /someresources/anId
1593
+
1594
+
PUT /someresources/anId
1595
+
{"anotherdata": "another value"}
1596
+
```
1597
+
1598
+
REST is focused on exposing data. It minimizes the coupling between client/server and is often used for public HTTP APIs. REST uses a more generic and uniform method of exposing resources through URIs, [representation through headers](https://github.com/for-GET/know-your-http-well/blob/master/headers.md), and actions through verbs such as GET, POST, PUT, DELETE, and PATCH. Being stateless, REST is great for horizontal scaling and partitioning.
1599
+
1600
+
#### Disadvantage(s): REST
1601
+
1602
+
* With REST being focused on exposing data, it might not be a good fit if resources are not naturally organized or accessed in a simple hierarchy. For example, returning all updated records from the past hour matching a particular set of events is not easily expressed as a path. With REST, it is likely to be implemented with a combination of URI path, query parameters, and possibly the request body.
1603
+
* REST typically relies on a few verbs (GET, POST, PUT, DELETE, and PATCH) which sometimes doesn't fit your use case. For example, moving expired documents to the archive folder might not cleanly fit within these verbs.
0 commit comments