REST six constraints: 2. stateless

2. stateless: 无状态

处理请求的必要状态包含在请求本身中,
请求的必要状态: URI, query-string parameters, body, or headers

服务器处理请求后回传给客户端的状态都包含在响应中:
headers, status and response body.

也就是说客户端和服务器之间通过 请求本身 和 响应本身 交换状态。

So what's the difference between state and a resource?

State, or application state, is that which the server cares about to fulfill a request—data necessary for the current session or request. A resource, or resource state, is the data that defines the resource representation—the data stored in the database, for instance. Consider application state to be data that could vary by client, and per request. Resource state, on the other hand, is constant across every client who requests it.

那么state和resoure之间的区别是什么? 状态或应用程序状态是服务器关心的,以满足当前会话或请求所需的请求数据。 资源或资源状态是定义资源表示的数据 - 例如,存储在数据库中的数据。 将应用程序状态视为可能因客户端和每个请求而异的数据。 另一方面,资源状态在请求它的每个客户端都是不变的。

state: 是服务器关心的, 以满足当前请求所需的请求数据;

resource: 定义资源表示的数据,例如存在数据库中的数据。

总结起来就是:

通过请求信息和响应信息交换状态, 状态: 是指数据的变更。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值