什么是 REST 架构中的 "Representation State"

What is "Representation State" in REST archtecture

我试图理解 REST 架构的原则,但我很难理解什么是具象状态以及它是如何传输的。

另外,here,我遇到了"representation of a resource"这个概念。 "representation of a resource" 是什么意思?这种抽象让我感到困惑...

来自 Roy Fielding 的 Ph.D。论文:

“Representational State Transfer is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state-machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use.”

也许,一个简单的例子将有助于理解抽象。

你可以看看这个教程

Learn REST: A RESTful Tutorial

它们分解了抽象的含义,这应该可以消除您在理解时可能遇到的任何困惑。

基本上资源代表一个东西。资源可以有不同的表示形式。把它想象成一个物品或事物的不同形状。

表示:

  • 如何操纵资源
  • 部分资源状态
    • 在客户端和服务器之间传输
  • 通常 JSON 或 XML
  • 示例:

    • 资源:人(托德)
    • 服务:联系信息 (GET)
    • 代表:
      • 姓名、地址、phone号码
      • JSON 或 XML 格式

该视频确实试图以一种非常容易理解的方式解释主题。他们解释了在

找到的 Roy Fielding 博士论文

http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm