• Modeling Resources
• Tools: Server and Client
• Real world problems
• Future
Slide 4
Slide 4 text
Modeling
Resources
Slide 5
Slide 5 text
The key abstraction
of information in
REST is a resource.
Slide 6
Slide 6 text
re·source /ˈrēˌsôrs/
A resource is a conceptual
mapping to a set of entities,
not the entity that
corresponds to the mapping
at any particular point in time.
Slide 7
Slide 7 text
Resources are not
just database records
Slide 8
Slide 8 text
Resources are the nouns.
HTTP methods are the verbs.
URIs are the identifiers.
Media types are the representations.
Slide 9
Slide 9 text
But what about transactions?
searches?
complex actions?
Slide 10
Slide 10 text
Don’t do this:
POST /accounts/1/transfer/500.00/to/2
Try this instead:
POST /transactions
{ “from”: 1, “to”: 2, “amount”: 500.00 }
Slide 11
Slide 11 text
Tools
Slide 12
Slide 12 text
Server-side
• Rails
• Active Model Serializers
• Custom Responders
• rack-test and json_spec
Slide 13
Slide 13 text
Client-side
• AFNetworking
• RestKit (if you really need it)
• VCRURLConnection and
mitmproxy
Slide 14
Slide 14 text
Real
World
Problems
Slide 15
Slide 15 text
Versioning
Don’t do this:
POST /v1/users/1
Try this instead:
POST /users/1
Accept: application/json; version=1.0
Slide 16
Slide 16 text
Authentication
• OAuth2 with API routes for token
generation
• NSURLConnection supports
cookies
• Basic Authentication over HTTPS*
Slide 17
Slide 17 text
Caching
• NSURLCache has support for
Cache-Control and ETags
• AFNetworking supports this by
default
• Rails gives you these for free
Slide 18
Slide 18 text
Smarter Requests
• Side loading associated
resources
• HTTP Pipelining for GET, HEAD,
PUT, and DELETE requests
• HTTP compression
Slide 19
Slide 19 text
Future
Slide 20
Slide 20 text
HTTP 2.0
• Based on SPDY
• Multiplexing
• Server Push
• Better compression
Slide 21
Slide 21 text
JSON API
• Standard hypermedia type
• Always namespaced
• Always returns collections for
easy parsing
• Support for batch operations
Slide 22
Slide 22 text
JSON Patch
• Standard hypermedia type for
updating records
• Easily handle associations
• Send minimal amount of
information