REST

What is REST

Representational State Transfer

So REST is essentially a set of constraints, the general architecture resembles the Web.

Constraints

The Client - Server constraint

  • Enforces a separation of concerns
  • Allows independent evolution of
    • Clients
      • such like browsers
    • Servers

The stateles constraint

  • Client-Server communication must be stateless between requests
  • A request should contain all necessary data for the Server to complete it
  • All session data should be returned to the client at the end of each Request
  • The client side must contain all the data related to the session

The cache constraint

  • Responses from the server are explicitly labeled as cacheable or non-cacheable
  • Requests pass through a cache component
  • The goal is to match the infrastructure of the existen Web infrastructure

The Uniform constrant constraint

  • The service and all clients must share a single uniform technical interface
  • To be reusable by a wide range of clients and over a broad range of interactions
  • It needs to provide generic, high-level, abstract capabilities

The Layered System Constraint

  • Builds on Client-Server to allow for intermediaries / middleware
  • These intermediaries must be transparent
  • Information Hiding
    • Simplifies distributed architecture

Terminology

  • Resourece
    • Any source of information, that can be refer to via a URI
  • Representation
    • The current state of the resource in a specific format
      • xml
      • json
  • Hypermedia Type
    • Specific format for the representation
    • we can build our own types
    • JSON by itself is not Hypermedia