restifarian
A RESTifarian is a zealous proponent of the REST
REST
REpresentational State Transfer
Is an architectural style for distributed systems
Conforming to the REST constraints is generally referred to as being "RESTful"
rest
The key abstraction of information in REST is a resource. Any
information that can be named can be a resource: a document or image, a
temporal service (e.g. "today's weather in Ra'anana")
REST components perform actions on a resource by using a representation
Resource based
Things (resources) vs actions
=
Nouns vs verbs:
(GET) scheduler/channels - getSchedulerChannels();Versus SOAP-RPC (Simple Object Access Protocol)
Identified by URIs
Multiple URIs (may) refer to the same resouce
Representations
A serialized description of a resource
Example:
-
Resource: channel (CNN)
-
Service: view meta data (GET)
-
Representation:
- call-sign, alias, multicast feed, etc
- JSON/XML format
HTTP
HTTP is a request/response protocol
request
response
http verbs
They mean something
rest constrains
- Uniform Interface
- Stateless
- Cache
- Client-Server
- Layered system
- Code on Demand
Uniform Interface
The uniform interface constraint defines the interface between clients and servers. It simplifies and decouples the architecture, which enables each part to evolve independently
HTTP verbs (CRUD)
URIs (resource name)
HTTP response (status, body)
Statless
- Server contains no client state
- Each request contains enough context to process the message (self descriptive messages)
- Any session state is held on the client
- Visibility
- Reliability
- Scalability
stateless
- Visibility is improved because a monitoring system does not have to look beyond a single request datum in order to determine the full nature of the request
-
Reliability is improved because it eases the task of recovering from partial failures
-
Scalability is improved because not having to store state between requests allows the server component to quickly free resources
Cache
As on the World Wide Web, clients/CDN can cache responses.
This gives us: The advantage of having the potential to partially or completely eliminate some interactions, improving efficiency
Each request must declare it's own caching rule:
- Implicitly
- Explicitly
- Negotiate
Client - server
- Separation of concerns is the principle behind the client-server constraint.
- By separating the user interface concerns from the data storage
concerns, we improve the portability of the user interface across
multiple platforms and improve scalability by simplifying the server
components.
- Components to evolve independently
layered system
A client does not need to know to whom it's connected.
By restricting knowledge of the system to a single layer, we place a
bound on the overall system complexity and promote substrate
independence
The primary disadvantage of layered systems is that they add
overhead and latency to the processing of data.
Code on demand
(optional)
Servers are able to temporarily extend or customize the functionality of a client by transferring logic to it that it can execute.
The reply can be javascript file, java applet
response types
Generally using the HTTP status code to describe the result
1xx: Infomration (100: continute...)
2xx: Success (200:ok, 201: created...)
3xx: Redirection (301: moved permanently)
4xx: Client error (400: bad request, 404: not found...
5xx: Server error (500: internal error, 501: not impl...)
Examples
In the wild
Resources
http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
Type 'what is RESTful service' in google...dahhhh
Demo
restafarian
By eyalmrejen
restafarian
- 2,350