REST
Representational State Transfer
whoami
Colin Harrington
[Link]@[Link]
colin@[Link]
[Link]
@ColinHarrington
History
HTTP :: HyperText Transfer Protocol
Tim Berners-Lee :: 1990s
Foundations of the Web
OSI Layer 7
Application Layer
Protocol
History
REST :: Representational State Transfer
2000 Doctoral Dissertation by Roy T. Fielding
[Link]
"Roy Thomas Fielding (born 1965) is an American computer
scientist
[1]
, one of the principal authors of the HTTP specification, an
authority on computer network architecture
[2]
and co-founder of the
Apache HTTP Server project." (Wikipedia)
[Link]
@fielding
History - REST
Architecture:
Client-Server
Stateless + Cacheable
Uniform Interface + Layerable
Data:
Resources, identifiers & metadata
Representation & metadata
Control Data { headers }
Elements:
{clients, server, resolver, cache}
Gateways, proxies, user agents
URL, URI, Schemes
REST
REST is a buzzword and a movement but it symbolizes a coherent
usage of the web (HTTP) as it was designed
REST ~ HTTP done right.
Resources
Uniform Resource Identifiers (URI)
<scheme>:<scheme-specified-structure>
[Link]
urn:issn:1535-3613
[Link]
Uniform Resource Locator (URL)
scheme://domain:port/path?query_string
HTTP Methods/Verbs
HEAD, GET, OPTIONS => considered "safe"
PUT, POST, DELETE => possibly destructive
TRACE, DEBUG => Considered harmful
curl -v [Link]
GET / HTTP/1.1
User-Agent: curl/7.21.0
Host: [Link]
Accept: */*
Accept Headers :: Client
GET / HTTP/1.1
User-Agent: curl/7.21.0
Host: [Link]
Accept: */*
Accept: application/xml
Accept: text/html,application/xhtml+xml,
application/xml;q=0.9,*/*;q=0.8,
application/json
HTTP Status Codes
200 - OK
301 - Moved permanently
302 - Moved temporarily
404 - Not Found
500
[Link]
HTTP/1.1 200 OK
Date: Mon, 31 Oct 2011 [Link] GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
[Link]
Representations
XML
JSON
HTML
XHTML
RDF
Text
Custom Formats
JSON Example
{
"firstName": "John",
"lastName" : "Smith",
"age" : 25,
"address" :
{
"streetAddress": "21 2nd Street",
"city" : "New York",
"state" : "NY",
"postalCode" : "10021"
},
"phoneNumber":
[
{
"type" : "home",
"number": "212 555-1234"
},
{
"type" : "fax",
"number": "646 555-4567"
}
]
}
Content Negotiation
Request:
Accept Header
Accept: application/xml
Accept-Language
Accept-Encoding
Response:
Content-Type: text/json
Accept: text/html,application/xhtml+xml,
application/xml;q=0.9,*/*;q=0.8,
application/json
Cacheability
HTTP Cache Headers
Expires
Cache-Control
ETag
Last-Modified
Pragma no-cache
Proxy & Network path.
CRUD
Create :: POST
Read :: GET
Update :: PUT
Delete :: DELETE
* [Link]
Hypermedia
Linking
to other resources / media
HTML documents, resources
loosely coupled
Images, CSS, favicon, etc.
Like this image ->
[Link]
Who
[Link]
Amazon Web Services
{S3, EC2, SQS, RDS, FPS, etc.}
Just to name a few...
Resources
This guy explains REST in to his non-technical wife:
[Link]
Good article on how to REST with curl:
[Link]
Poster -- the Firefox plugin:
[Link]
You'd probably learn best by actually making some RESTful
calls. Pick a service that is free and RESTful and play around with it. I'd
recommend using [Link] just because they offer you
$30 in free credit and you get to make, receive and control real phone
calls.
Thank You