The document discusses Representational State Transfer (REST), an architectural style for distributed hypermedia systems. It describes the key building blocks of REST including HTTP, URIs, URLs, request methods (GET, POST, PUT, PATCH, DELETE), and status codes. Examples are provided to illustrate how REST can be used to retrieve a resource count, schedule a task to reset a temperature sensor, and return appropriate status codes as the task is processed and completed. The importance of hypermedia and HATEOAS for developing mature RESTful APIs is highlighted.
3. REST is an abbreviation for…
a) Really Strange Topic
b) Relational Enterprise Scheme Trade
c) Representational State Transfer
d) ??? [use “send a comment”]
14. Use PUT to create or replace resources
if you know their exact URL
Otherwise, POST to the parent resource
15. Use PUT to replace a whole resource at once,
PUT operations must be idempotent!
Use PATCH to update partial data
16. We have a list of items, e.g. /messages
How do we get the number of all messages?
a) GET /messages and {…count: 5…}
b) GET /messages/count
c) GET /messages?count
d) ??? [use “send a comment”]
17. We have a list of items, e.g. /messages
How do we get the number of all messages?
> HEAD /messages
< …
< X-COUNT: 5
18. We GET the current temperature from
/house/livingroom/temp. But the sensor is
kinda unstable and needs to be power-cycled
from time to time. How would you do it?
a) POST /house/livingroom/temp/reset
b) PUT /house/livingroom/temp/reset
c) DELETE /house/livingroom/temp
d) ??? [use “send a comment”]
19. We GET the current temperature from
/house/livingroom/temp. But the sensor is
kinda unstable and needs to be power-cycled
from time to time. How would you do it?
> POST /house/scheduledTasks
> {
> time: ‘now’,
> action: ‘reset’,
> target: ‘livingroom/temp’
> }
20. HTTP is kinda bad
for long-running processes
No, you´re just
using it wrong
31. Why 404 has no ‘double meaning’
> GET /house/scheduledTasks/1234567890
< HTTP/1.1 404 Not Found
> GET /house/scheduledTasks/7dhe9u
< HTTP/1.1 410 Gone
> GET /house/scheduledTasks/8fks3k
< HTTP/1.1 200 OK
> GET /house/scheduledTasks/9edm4d
< HTTP/1.1 200 OK
32. Why 404 has no ‘double meaning’
> GET /houes/scheduledTasks/1234567890
< HTTP/1.1 404 Not Found
> GET /houes/scheduledTasks/7dhe9u
< HTTP/1.1 404 Not Found
> GET /houes/scheduledTasks/8fks3k
< HTTP/1.1 404 Not Found
> GET /houes/scheduledTasks/9edm4d
< HTTP/1.1 404 Not Found