RESTful 笔记 #25
onnttf
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
REST 是什么
REST
,并不是简单的四个字母,它是Representational State Transfer
的缩写,可译为"表现层状态转化”。看不懂没关系,在前面加一个
Resource
,就可以很好的理解了:资源在网络中以某种表现形式进行状态转移Resource
这边的
Resource
指的就是我们的资源、数据等,可以用一个 URI(统一资源定位符)指向它,每种资源对应一个特定的 URI。要获取这个资源,访问它的 URI 就可以,因此 URI 就成了每一个资源的地址或独一无二的识别符。Representational
资源的表现形式,比如我们常见的:
具体表现形式,在
HTTP
请求的头信息中用Accept
和Content-Type
字段指定State Transfer
客户端和服务器的一个互动过程,势必涉及到数据和状态的变化。
互联网通信协议 HTTP 协议,是一个无状态协议。这意味着,所有的状态都保存在服务器端。因此,如果客户端想要操作服务器,必须通过某种手段,让服务器端发生"状态转化"。而这种转化是建立在表现层之上的,所以就是"表现层状态转化"。
RESTful API
特点
简单来讲就是:
Url
就知道要什么http method
就知道干什么http status code
就知道结果如何优点
附
Beta Was this translation helpful? Give feedback.
All reactions