rest
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| rest [2018/02/28 14:39] – [What makes REST different from SOA or HTTP-based interfaces] skipidar | rest [2023/06/06 09:53] (current) – skipidar | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| Es werden Methoden übergeben: | Es werden Methoden übergeben: | ||
| - | | |GET | POST | PUT | DELETE| PATCH| | + | | | GET | POST | PUT | DELETE| PATCH| |
| - | |Safe|x| | | | | | + | |Safe | x | | |
| - | |Idempotent|x|x| |x| | | + | |Idempotent| |
| Line 14: | Line 14: | ||
| A good describtion is here: \\ | A good describtion is here: \\ | ||
| - | http://www.se.uni-hannover.de/pub/ | + | https://restfulapi.net/idempotent-rest-apis/ |
| Line 25: | Line 25: | ||
| - | ===== compare | + | ===== Maturity of REST ====== |
| {{https:// | {{https:// | ||
| - | ==== What makes REST different from SOA or HTTP-based interfaces | + | ==== What makes REST architecture mature? 4 steps ==== |
| https:// | https:// | ||
| Line 61: | Line 61: | ||
| </ | </ | ||
| + | |||
| + | |||
| + | === Glossary === | ||
| + | | Compound Documents | < | ||
| + | To reduce the number of HTTP requests, servers MAY allow responses that include related resources along with the requested primary resources. Such responses are called “compound documents”. | ||
| + | https:// | ||
| + | </ | ||
| + | |Sparse Fieldsets| A client MAY request that an endpoint return only specific fields in the response on a per-type basis by including a fields[TYPE] parameter. < | ||
| Line 70: | Line 78: | ||
| Characteristics: | Characteristics: | ||
| * tunneling a mechanism for an own RPC - remote interaction mechanism. **But to special URIs** - not one service. | * tunneling a mechanism for an own RPC - remote interaction mechanism. **But to special URIs** - not one service. | ||
| - | * **using Resources**. On the URI too like **/ | + | * **using Resources**. On the URI too like **/ |
| Request: | Request: | ||
| Line 113: | Line 121: | ||
| - | === 3. Using HTTP Verbs === | + | === 2. Using HTTP Verbs === |
| Characteristics: | Characteristics: | ||
| * tunneling a mechanism for an own RPC - remote interaction mechanism. **But to special URIs** - not one service. | * tunneling a mechanism for an own RPC - remote interaction mechanism. **But to special URIs** - not one service. | ||
| * **using Resources**. On the URI too like **/ | * **using Resources**. On the URI too like **/ | ||
| - | * **Using GET, POST, PUT, DELETE, PATCH - similarly to HTTP**. GET is safe. POST, DELETE, PATCH are not. | + | * **Using GET, POST, PUT, DELETE, PATCH - similarly to HTTP**. GET is safe. POST, DELETE, PATCH are not. \\ Level 2 introduces a standard set of verbs so that we handle similar situations in the same way, removing unnecessary variation. |
| + | |||
| Request: | Request: | ||
| < | < | ||
| - | GET /doctors/mjones/slots/ | + | GET /slots/? |
| </ | </ | ||
| Line 156: | Line 166: | ||
| </ | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | HTTP/1.1 409 Conflict | ||
| + | |||
| + | < | ||
| + | <slot id = " | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | === 3. HATEOAS - Hypermedia As The Engine Of Application State === | ||
| + | |||
| + | Characteristics: | ||
| + | * tunneling a mechanism for an own RPC - remote interaction mechanism. **But to special URIs** - not one service. | ||
| + | * **using Resources**. On the URI too like **/ | ||
| + | * **Using GET, POST, PUT, DELETE, PATCH - similarly to HTTP**. GET is safe. POST, DELETE, PATCH are not. | ||
| + | * The **references** to **next steps** are **embedded dynamically** into the response. Allowing to develop the client separately from the server. It allows the server to change its URI scheme without breaking clients. https:// | ||
| + | |||
| + | Request | ||
| + | < | ||
| + | POST /slots/1234 HTTP/1.1 | ||
| + | |||
| + | < | ||
| + | <patient id = " | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Response | ||
| + | < | ||
| + | HTTP/1.1 201 Created | ||
| + | Location: http:// | ||
| + | |||
| + | < | ||
| + | <slot id = " | ||
| + | <patient id = " | ||
| + | <link rel = "/ | ||
| + | uri = "/ | ||
| + | <link rel = "/ | ||
| + | uri = "/ | ||
| + | <link rel = " | ||
| + | uri = "/ | ||
| + | <link rel = "/ | ||
| + | uri = "/ | ||
| + | <link rel = "/ | ||
| + | uri = "/ | ||
| + | <link rel = "/ | ||
| + | uri = "/ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ==== HAL - Hypertext Applicaiton Language ==== | ||
| + | |||
| + | **REST** is a concept of application architecture. Its multiple maturity states are defined above: Stack of POX, Ressource, Verbs etc. | ||
| + | |||
| + | |||
| + | **HATEOAS** is a concept of application architecture. It defines the way in which application clients interact with the server, by navigating hypermedia links they find inside resource models returned by the server. | ||
| + | |||
| + | To implement HATEOAS you need some standard way of representing resources, that will contain hypermedia information (links to related resources), for example, something like this: | ||
| + | |||
| + | |||
| + | **HAL** is one of such standards. It is a specific format of resource presentation, | ||
| + | |||
| + | |||
| + | * HAL Introduction: | ||
| + | * HAL browser: http:// | ||
| ===== REST API Example ===== | ===== REST API Example ===== | ||
| Line 262: | Line 342: | ||
| </ | </ | ||
| + | |||
| + | |||
| + | == CURIES == | ||
| + | Cut URI - an approach to reduce the long URLs | ||
| + | |||
| + | < | ||
| + | GET http: // | ||
| + | data{ | ||
| + | id: 1, | ||
| + | type: characters, | ||
| + | attributes{ | ||
| + | name: " | ||
| + | size: " | ||
| + | race: " | ||
| + | }, | ||
| + | curies{ | ||
| + | { | ||
| + | name: " | ||
| + | href: " | ||
| + | }, | ||
| + | links{ | ||
| + | self: " | ||
| + | prev: " | ||
| + | next: " | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
rest.1519828741.txt.gz · Last modified: (external edit)
