What does Representational State mean in REST?

前端 未结 8 754
执笔经年
执笔经年 2021-01-30 02:58

I have been reading all over the net to get the exact meaning of two words:

REPRESENTATIONAL STATE

I have a doubt. I am misunderstanding these terms. i want to

8条回答
  •  逝去的感伤
    2021-01-30 03:38

    Copying from my blog

    REST is about creating representation(like JSON or xml or any other format.) of object's current state(like data in database) and transferring that representation over network. Rest is the set of constraint/convention.

    Resources are decoupled from their representation so that their content can be accessed in a variety of formats, such as HTML, XML, plain text, PDF, JPEG, JSON, and others. Metadata about the resource is available and used, for example, to control caching, detect transmission errors, negotiate the appropriate representation format, and perform authentication or access control

    At ground level , Rest is nothing more but a collection of principles

    1. Communication should be stateless : Server should not store any state . If required it should be part of message

    2. State should be representational : Internally resource at server can be in one form but it should be able to change it representation. An object referenced by one URI can have different formats available. Different platforms need different formats. Mobile may need JSON whereas desktop may need XML

    3. HTTP verbs like GET, POST, PUT, and DELETE must be followed religiously.

    4. Resources should be addressable : Every resource on your network should have an specific address(specific URI)

提交回复
热议问题