RFC2119:
MUST, SHALL, REQUIRED
SHOULD, RECOMMENDED
MAY, OPTIONAL
MUST NOT, SHALL NOT
SHOULD NOT, NOT RECOMMENDED
Slide 18
Slide 18 text
E.g.:
Response representations MUST begin with
element as the first element
Slide 19
Slide 19 text
Servers SHOULD return a response code of
204 if the HTTP DELETE request was
successful.
Slide 20
Slide 20 text
Document MAY contain a single filters object.
Five properties: href(REQUIRED), rel
(REQUIRED), name (OPTIONAL), prompt
(OPTIONAL), and a data array (OPTIONAL)
*MIME types are registered in IANA w/ public
access
Slide 33
Slide 33 text
HTTP:
Slide 34
Slide 34 text
HTTP verbs:
GET
HEAD
POST
PUT
PATCH
DELETE
OPTIONS
Slide 35
Slide 35 text
HTTP verbs:
GET
HEAD
POST
PUT
PATCH
DELETE
OPTIONS
Slide 36
Slide 36 text
Status codes:
100.upto(505).almost_each do |status_code|
…
end
Slide 37
Slide 37 text
100 Continue
201 Created
202 Accepted
206 Partial Content
303 See Other
400 Bad Request
401 Unauthorized
404 Not Found
409 Conflict
412 Precondition Failed
417 Expectation Failed
Slide 38
Slide 38 text
100 Continue
201 Created
202 Accepted
206 Partial Content
303 See Other
400 Bad Request
401 Unauthorized
404 Not Found
409 Conflict
412 Precondition Failed
417 Expectation Failed
Slide 39
Slide 39 text
100 Continue
201 Created
202 Accepted
206 Partial Content
303 See Other
400 Bad Request
401 Unauthorized
404 Not Found
409 Conflict
412 Precondition Failed
417 Expectation Failed
Slide 40
Slide 40 text
100 Continue
201 Created
202 Accepted
206 Partial Content
303 See Other
400 Bad Request
401 Unauthorized
404 Not Found
409 Conflict
412 Precondition Failed
417 Expectation Failed
Slide 41
Slide 41 text
100 Continue
201 Created
202 Accepted
206 Partial Content
303 See Other
400 Bad Request
401 Unauthorized
404 Not Found
409 Conflict
412 Precondition Failed
417 Expectation Failed
Slide 42
Slide 42 text
100 Continue
201 Created
202 Accepted
206 Partial Content
303 See Other
400 Bad Request
401 Unauthorized
404 Not Found
409 Conflict
412 Precondition Failed
417 Expectation Failed
Slide 43
Slide 43 text
Request headers:
OPTIONS /payment/order/1234
HTTP 1.1
Host: starbucks.example.com
Response
200 OK Allow: GET, PUT
HTTP Headers:
Accept/type
Etag
Cache
Authorization
Version
If-Unmodified-Since
If-Match
Slide 49
Slide 49 text
HTTP Headers:
Accept/type
Etag
Cache
Authorization
Version
If-Unmodified-Since
If-Match
Slide 50
Slide 50 text
Media types (revisited):
Accept: application/xml
Accept: application/json
Slide 51
Slide 51 text
GET https://api.github.com/gists/1
Accept: application/json
200 OK
Content-Type: application/json; charset=utf-8
(response body)
Slide 52
Slide 52 text
GET https://api.github.com/gists/1
Accept: application/xml
200 OK
Content-Type: application/xml; charset=utf-8
(response body)
Slide 53
Slide 53 text
GET https://api.github.com/gists/1
Accept: application/xml
406 Not Acceptable
Content-Type: application/json
{
"message": "Must ACCEPT application/json:
[\"application/xml\"]"
}
Slide 54
Slide 54 text
HTTP Headers:
Accept/type
Etag
Cache
Authorization
Version
If-Unmodified-Since
If-Match
Slide 55
Slide 55 text
GET https://api.github.com/gists/1
Accept: application/json
200 OK
ETag: "2259b5bea67655550030acf98bad4184"
{body}
GET https://api.github.com/gists/1
Accept: application/json
If-None-Match:
"2259b5bea67655550030acf98bad4184"
304 Not Modified
Slide 56
Slide 56 text
HTTP Headers:
Accept/type
Etag
Cache
Authorization
Version
If-Unmodified-Since
If-Match
Slide 57
Slide 57 text
Authentication:
Basic HTTP Authentication
(with SSL or Digesting)
Slide 58
Slide 58 text
HTTP Headers:
Accept/type
Etag
Cache
Authorization
Version
If-Unmodified-Since
If-Match
Slide 59
Slide 59 text
Accept: application/vnd.example+json
Accept: application/vnd.example+json;version=1.0
Accept: application/vnd.example-v2+json
Start point URI remains: http://api.example.com
Slide 60
Slide 60 text
HTTP Headers:
Accept/type
Etag
Cache
Authorization
Version
If-Unmodified-Since
If-Match
Slide 61
Slide 61 text
Richardson Maturity Model
Slide 62
Slide 62 text
1. “The Swamp of POX.” You’re using HTTP
to make RPC calls. HTTP is only really used
as a tunnel.
http://api.example.com?post_id=1&user_id=2
Slide 63
Slide 63 text
2. Resources. Rather than making every call
to a service endpoint, you have multiple
endpoints.
http://api.example.com/posts/edit/1
http://api.example.com/users/show/1
Slide 64
Slide 64 text
3. HTTP Verbs.
GET http://api.example.com/posts/1
PUT http://api.example.com/posts/1
PATCH http://api.example.com/posts/1
POST http://api.example.com/posts
DELETE http://api.example.com/posts/1