RESOURCES
26
▫︎Can also represent abstract concepts:
▫︎Employees in a enterprise
▫︎Money transfers
▫︎Products in a online store
▫︎Calendar appointments
▫︎User accounts
RESOURCE IDENTIFIERS
31
A resource only exists on the Web if it has an
identifier (URI)
Slide 32
Slide 32 text
RESOURCES
32
HTTP can manipulate not only hypertext
documents but any type of resources
Slide 33
Slide 33 text
Imaginary HTTP server:
example.com
33
Slide 34
Slide 34 text
READING A TEXT RESOURCE
34
http://example.com/hello-world.txt
Slide 35
Slide 35 text
READING A TEXT RESOURCE
35
GET /hello-world.txt HTTP/1.1
Host: example.com
HTTP Request
Slide 36
Slide 36 text
READING A TEXT RESOURCE
36
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 13
Hello, World!
HTTP Response
Slide 37
Slide 37 text
CREATING A TEXT RESOURCE
37
POST / HTTP/1.1
Host: example.com
Content-Type: text/plain
Hello, Mars!
HTTP Request
Slide 38
Slide 38 text
CREATING A TEXT RESOURCE
38
HTTP/1.1 201 Created
Location: /hello-mars.txt
HTTP Response
Slide 39
Slide 39 text
CREATING A TEXT RESOURCE
39
http://example.com/hello-mars.txt
Slide 40
Slide 40 text
RESOURCE DOES NOT EXIST
40
http://example.com/hello-pluto.txt
Slide 41
Slide 41 text
RESOURCE DOES NOT EXIST
41
GET /hello-pluto.txt HTTP/1.1
Host: example.com
HTTP Request
Slide 42
Slide 42 text
RESOURCE DOES NOT EXIST
42
HTTP/1.1 404 Not Found
HTTP Response
Slide 43
Slide 43 text
HTTP CONTENT TYPES
43
▫︎Determine the type of the HTTP payload
▫︎text/html - HTML
▫︎text/plain - Plain Text
▫︎audio/mpeg3 - MP3 files
▫︎application/xml - XML
▫︎…
HATEOAS
84
Hypermedia As The Engine of Application State
Slide 85
Slide 85 text
UNIFORM INTERFACE
85
▫︎Create: POST /employees
▫︎Read: GET /employees/alice
▫︎Update: PUT /employees/alice
▫︎Delete: DELETE /employees/alice
▫︎List: GET /employees
Slide 86
Slide 86 text
UNIFORM INTERFACE
86
▫︎Create: POST /resource
▫︎Read: GET /resource/{name}
▫︎Update: PUT /resource/{name}
▫︎Delete: DELETE /resource/{name}
▫︎List: GET /resource
Slide 87
Slide 87 text
SAFETY
87
GET and HEAD never change the resource
state
Slide 88
Slide 88 text
INDEMPOTENCE
88
PUT and DELETE are indempotent
Slide 89
Slide 89 text
RESTFUL
WEB SERVICES
89
Slide 90
Slide 90 text
WEB SERVICES
90
client
server
Web
Slide 91
Slide 91 text
BIG WEB SERVICES
91
▫︎Heavy
▫︎Don’t scale
▫︎Hard to understand
▫︎Tight coupling
▫︎SOAP, WSDL, etc…
Slide 92
Slide 92 text
TIGHT COUPLING
92
Slide 93
Slide 93 text
BROKEN TIGHT COUPLING
93
Slide 94
Slide 94 text
RESTFUL WEB SERVICES
94
▫︎Lightweight
▫︎Cacheable
▫︎Scalable
▫︎Discoverable
▫︎Loose coupling