对“REST"的误解是什么?词和它的意思 [英] In what do consist the misunderstandings about the "REST" word and its meaning

查看:55
本文介绍了对“REST"的误解是什么?词和它的意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

弄清楚什么是真正的 RESTFull 应用程序和/或 api 并不总是那么容易,因为对 REpresentational State Transfer 架构风格的含义和范围存在一种误解.

It is not always easy to figure what is really a RESTFull application and/or api, because there is a sort of misunderstanding about the REpresentational State Transfer architectural style meaning and scopes.

最初,我对首字母缩略词 REST 的形容词REpresentational"所指的内容感到非常困惑.这是因为表象状态"对我来说听起来不太好..

Initially, I was quite in trouble on what, the adjective "REpresentational" of the acronym REST, referred. This was because "representational state" sounded to me not so well..

此外,博客文章也给我留下了深刻的印象 这种架构风格的作者 Roy Fielding,他对经常被误解的基于 http 动词的 api 是 Restfull 感到非常失望,特别是他抱怨这些 api 的客户端和服务器之间的耦合.名称和数据结构.

Further, I was impressed also by a blog post of the author of this architectural style, Roy Fielding, where he is a lot disappointed about the frequent misunderstading that api based on http verbs are Restfull, in particular he complaints about the coupling among client and server of these api regarding their names and data structures.

博客文章参考:http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven

我想尝试仅给出有关 REST arch 的理论解释.风格,我想知道其他观点.

I want try to give only a theoric explanation about REST arch. style and I'd like to know other points of view.

推荐答案

第一部分

我的主要目标是将注意力集中在具象状态转移"这个名称的原因上.

我认为对 REST 的大部分误解都归于形容词代表性".大多数人认为代表性"一词与资源状态有关,因此构建专注于对象结构的应用程序以与调用客户端进行通信/传输..但我认为重点是传输",它是传输具有代表性",因此重要的设计应用程序(或 api)利用它们所依赖的 REST 网络系统的代表性"能力来支持客户端-服务器组件之间的传输.

I think that the most of misundertandings about the REST goes under the adjective "representational". Most people think that "representational" word relates to the resource state and so builds application focusing on object structures to communicate/transfer to the calling clients.. but I think that the focus is the "transfer", it is the transfer to be"representational", and so it is important design applications (or api) that make use of the "representational" ability of the REST network system on that they rely, to support transfers among client-server components.

要弄清楚 REST 架构风格所关注的整个问题,需要了解作者 Roy Fielding 在他的论文中打算提出一套架构原则来构建基于超文本或超媒体的架构范式,因此该范式是理解这一重要主题的核心关键.

To figure out the whole question about the concern of the REST architectural style, it needs to understand that the author, Roy Fielding, intended to suggest in his dissertation, a set of architectural principles to build architectures based on the hipertext or hipermedia paradigm, and so this paradigm is the central key to understand this important topic.

在 Roy Fielding 提出的组织客户端 - 服务器应用程序架构的风格背后,我认为有一个现代客户端 - 服务器应用程序的特定想法,它由一种管理应用程序状态转换的引擎组成,其状态是可扩展到无限.

Behind the style of organizing a client-server application's architecture proposed by Roy Fielding, I think there is a specific idea of a modern client-server application, that consists by a sort of engine to govern application state transition, whose states are potentially extensible to infinite.

在这个愿景中,Ipertext\Ipermedia 是 Fielding 提出的整个架构风格的中心,让这种范式发挥作用的关键概念是表征(状态)转移".

In this vision, the Ipertext\Ipermedia is the center of the whole architectural style proposed by Fielding and the key concept that allows this paradigm to work is the "representational (state) transfer".

所以我们可以理解为什么representational"这个词指的是transfer"的概念,而不是state"的概念.因为它是具有代表性的(具有代表性的类型)传输,这意味着 它是管理传输"的系统,并且依赖于客户端 - 服务器交互,以给出有关表示的一些标准指示,这就是媒体类型的概念(或 REST 的 Web 实现中的 MIME),在我看来,这就是具象状态转移"这个名称的主要原因.

So we can understand why the word "representational" refers to the concept about the "transfer", instead of the concept about "state". Because it is the transfer to be representational (of a representational type), and this means that it is the system that manages the "transfers" and on which relies the client-server interaction, to give some standard indication about the representation, that is the media-type concept (or MIME in the web implementation of the REST) and that is, in my opinion, the main cause of the name "Representational State Transfer".

因此,设计 Restfull 应用程序,首先要设计一个基于组件网络的架构,每个组件都在客户端-服务器分层架构模型中与其他组件通信,向每个组件发送其状态的表示.

So, designing a Restfull application, it is design first an architecture based on a web of components, each of them comunicates with others in a client-server layered architecture model, sending each of them a representation of its state.

因此,前端,这个架构的第一个客户端,通过它的状态转换,显示由一个或多个组件发送的状态的表示,它在统一一致的接口上调用背书,而不是在私有" api.

And so, the front-end, the first client of this architecture, transits through its states showing rapresentation of the states sended by the component, or components, that it calls endorsing on a uniform consistent interface and not on a "private" api.

在作者看来,这种类型的应用程序可能会扩展到无限状态,因为它的状态不依赖于私有 api,而是依赖于所有代理共享的唯一标识符系统(如 URI)在此架构中,使用一些动词来管理其状态的转换,以及约定的共享表征传输系统,或者加上.

A such type of application, in the mind of the author, is potentially extensible to infinite states, because its states don't depend on a private api, but depend on a univoque identifier system (as URI) shared by all agents in this architecture, on a few some verbs to manage transion of its states and on an agreed shared representational transfer system, or plus.

此转换以通过构成公共"api 的动词将其表示形式传达给被调用的服务器组件而结束,公共"api 应属于客户端-服务器组件使用的无状态通信协议.

This transition ends with communication of its representation to the called server component via the verbs that compose the "public" api, which should belong to the stateless communication protocol used by the client-server components.

以这种方式,这种客户端-服务器组件交互包括基于无状态协议的使用交换(传输、通信)组件状态的标准化表示(媒体类型).

In such a way, this client-server components interaction consists in interchanging (transferring, communicating) of standardized representations (media types) of components states, based on use of a stateless protocol.

允许所有这些架构将自身扩展到无限的核心概念是将组件的资源结构和名称与其客户端标识和表示(表示转移)解耦.

第二部分

有关媒体类型和 RESTful 应用程序构建的更多详细信息

我认为 Fielding 的最初直觉是这样一种想法,即允许分布式应用程序架构中客户端和服务器组件之间完全解耦且可无限扩展的关键特性是定义一个开放且不断发展的标准表示集,以及这些组件交换此类表示以及在客户端解释它们的能力.

I think that the original intuition of Fielding was been the idea that a key feature to allow full decoupling between client and server components in a distributed application architecture, and indefinitely extensible, was the definition of an open and evolving standard representations set, and thus the ability of these components to exchange such representations and in the case of the client to interpret them.

这就是具象转移"的原因!

That's why "representational transfer"!

即,基于标准化的 rappresentations 的转移.相反,状态"正是以标准方式表示的内容,因为任何支持 REST 原则的客户端组件都可以理解它,并且允许表示本身成为包含在其媒体类型表示中的状态转换的引擎以及标准信息处理,它们应该指一小组与客户端-服务器通信协议相关的标准动词.

Namely, transfers based on standardized rappresentations. Instead, "state" is precisely what is represented in the standard way because it is understood by any client component that supports REST principles, and allows the representation itself to be the engine of the state transitions containing in its mediatype representation also the standard information handling, which them should refer to a small set of standard verbs related to the client-server communication protocol.

因此,构建遵循标准 REST 的应用程序(或从 REST 的角度来看的连接器),因此是 RESTful,意味着:

Therefore, to build applications (or connectors from the point of view of REST) adhering to the standard REST and therefore RESTful, means:

  1. 为自己的资源设计uri;

  1. designing uri for own resources;

使这些 uri 始终可用于发送给客户端的表示;

making these uri always available into representations sended to the clients;

专注于设计最合适的媒体类型表示,以支持自己的应用程序流,以及相同的状态转换.

focusing in design the most appropriate media type representations to support own application flow, and so the same state transitions.

这意味着在任何类型的设备上支持任何类型的媒体,还支持任何类型的交互系统或转换状态(例如自动化系统,而不仅仅是用户)

This means to support any type of media on any type of device and also support any type of interaction system or transition states (eg automated systems not only user)

这篇关于对“REST"的误解是什么?词和它的意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆