Thursday, April 13, 2017

Resources in REST


  • Client consumes servers capability by interacting with resources
  • Resources are identified by a resource identifier.In http terms this is an URL
  • Client interacts with resources the client does not work directly with the resources but with representations of those resources
         Example Person can be identified by name. We directly do not work with the Person by representation of person using JSON or XML. The message should also contain meta data about what to do with the services



Statelessness
  • Statelessness makes the state available to the components. Self descriptive messages make it intelligible
  • HyperMedia makes the server and the client decoupled by enabling clients to progress through a work flow by following server generated links
 Resource Identifier
  • Identifies a resource in a component interaction
  • Server is responsible for ensuring that the mapping semantics between identifier and entities do not change
  • Resource identify should change ads frequently
  • Should not think of resources as an entity
           
Resource identifiers in HTTP

Resource Meta Data

  • Data that describes the resource
          Ex: The location identifier of the resource
                Alternate resource identifier for different formats
                Entity tag information

  • In http all types of meta data are flattened in a same place in message exchange in HTTP headers

   In this example location and Etag headers are tied directly to the resource
   Location header is a link and actual the resource identifier
   Etag represents the state

Representation

  • Resource state at point of time
  • Can be any sequence of bytes
  • A resource can have multiple available representations
  • Content negotiation is the process of selecting the best representation of a resource

Representation Metadata

  • Data that describes the representation. The goal of this meta data is the help the client and server to know what to do otherwise opaque white standard
  • Helps the client or the server to know how to process the bytes
    • Hows its structure
    • What it means

 Bolded headers qualifies as representational meta data

      Server driven content negotiation
                         
   Requesting different representation. Here we are requesting image representation.
   
Control data in the header
In this example the bolded headers response gives us the state

No comments:

Post a Comment