gpt4 book ai didi

web-services - REST (RESTful) Web 服务是否与 HTTP 绑定(bind)(耦合或需要)?

转载 作者:可可西里 更新时间:2023-11-01 15:26:54 26 4
gpt4 key购买 nike

标题基本上说明了一切,REST 真的与 HTTP 绑定(bind)还是独立于协议(protocol)?因为我刚刚看了一些关于 REST 的文章,我遇到了两种观点,所以我不知道哪个是正确的。

最佳答案

请允许我引用这本书"RESTful Web Services" (粗体是我的):

The Story of the REST

REST is simple, but it’s well defined and not anexcuse for implementing web services as half-assed web sites because“they’re the same.” Unfortunately, until now the main REST referencewas chapter five of Roy Fielding’s 2000 Ph.D. dissertation, which is agood read for a Ph.D. dissertation, but leaves most of the real-worldquestions unanswered. That’s because it presents REST not as anarchitecture but as a way of judging architectures. The term “RESTful”is like the term “object-oriented.” A language, a framework, or anapplication may be designed in an object-oriented way, but thatdoesn’t make its architecture the object-oriented architecture. Evenin object-oriented languages like C++ and Ruby, it’s possible to writeprograms that are not truly object-oriented. HTTP in the abstract doesvery well on the criteria of REST. (It ought to, since Fieldingco-wrote the HTTP standard and wrote his dissertation to describe thearchitecture of the Web.) But real web sites, web applications, andweb services often betray the principles of REST. (...)

注意第二个粗体,他是说:“HTTP 非常适合 REST”,而不是“REST 适合/依赖于 HTTP”。

因此,简而言之:不,术语“REST”不一定与 HTTP 相关联。 RESTful web services 只是遵循 RESTful 架构的 web 服务,希望能够实现 Fielding 在其论文中列出的好处(如无状态、可寻址性等)。

创建 RESTful Web 服务的一种方法是根据资源(而不是 SOAP 样式使用的操作)来考虑您的应用程序。这种思维方式与 HTTP(其方法和状态代码)的正确使用相结合可以导致支持 REST 的架构,正如 Fielding 的论文所列举的(并具有所有好处)。

关于web-services - REST (RESTful) Web 服务是否与 HTTP 绑定(bind)(耦合或需要)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21080755/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com