What does “state transfer” in Representational State Transfer (REST) refer to?

前端 未结 3 491
面向向阳花
面向向阳花 2020-12-25 14:42

What does the State Transfer in Representational State Transfer refer to?

Found some explanations about this (e.g. here) but I still don\'t understa

3条回答
  •  余生分开走
    2020-12-25 15:39

    Why? What does state (as I understand it, something like a session) have to do with a representation of a resource?

    An object has attributes (or state) and behaviors (or methods).

    If I want to move an object from my desktop to a server I have to do the following:

    1. Create a representation of the state of the object.

    2. Transfer that representation from the desktop to the server.

    The methods I don't transfer. I install the same class definition on both machines.

    So, REST is about creating a representation of the object's current state so it can be transferred to another server from which the object can be reconstructed.

    We only send the state -- the attributes -- of the object. And we have to create an external, serialized representation of that state.

提交回复
热议问题