本文介绍了难道ST(状态传输)在REST意味着国家必须由客户在哪里举行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读<一个href=\"http://stackoverflow.com/questions/4603653/what-does-state-transfer-in-re$p$psentational-state-transfer-rest-refer-to\">What不状态转移,在重新presentational状态传输(REST)是指什么?以及关于REST的几个帖子或录像,我知道的REST的约束是无状态的。


  1. 据许多岗位如,使建筑无国籍,客户必须持有足够的信息,以便服务器做正确的事情,这意味着服务器没有任何客户端的状态。因此,它意味着我们只有构建一个REST应用,只有通过把一些用户状态在客户端如cookie?


  2. 但据很多帖子像Pros和粘性会话/会话关联的负载blancing策略的缺点?,我们可以通过存储在数据库或内存缓存中的用户数据,从而避免在应用服务器存储会话使一个无状态的应用程序。如果我们尝试这种方法,我们可以做一个REST架构?



解决方案

诚信REST的服务理念是允许它容易沟通,任何客户端,甚至到了客户端,是不是在网络浏览器:它可能是移动或桌面应用程序或其他任何东西。因此,每个请求到服务必须提供所有必要的信息来处理该请求。保持服务器的状态会在工作,因为客户端将无法控制它复杂化。

所以,是的,理想状态必须由客户持有。的的,我们需要清楚地明白我们的意思是国家。由于有各种不同的状态在那里的:应用的状态,的资源的状态。我喜欢下面的的区别

P.S。
和BTW,保持状态,将饼干以及(如果他们不是网络浏览器)复杂的生活给客户。

I read What does "state transfer" in Representational State Transfer (REST) refer to? and several post or videos about REST, and I know one of the constraint of REST is stateless.

  1. According to many posts like http://www.restapitutorial.com/lessons/whatisrest.html ,to make the architecture stateless, the client must hold the enough information for the server to do the right thing, which means the server does not have any client state. So does it mean we are only about to build a REST application only through putting some user state in the client like cookie?

  2. But according to many posts like Pros and Cons of Sticky Session / Session Affinity load blancing strategy? , we can make a stateless application by storing the user data in database or memcache, which avoid storing session in the application server. If we try this approach, can we make a REST architecture?

解决方案

The idea of honest REST service is to allow easy communication with it to any client, even to the client that is not in a web browser: it could be mobile or desktop application or anything else. So, each request to the service must provide all necessary information to process that request. Keeping the state on server would complicate the task, because clients will not control it.

So, YES, ideally state must be held by clients. BUT, we need to understand clearly what we mean by "state". Because there are different kinds of state out there: Application state, and Resource state. I like the following article about the distinction.

P.S.And BTW, keeping state in cookies would complicate life to clients as well(if they are not web-browsers).

这篇关于难道ST(状态传输)在REST意味着国家必须由客户在哪里举行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 10:58