RESTful architecture simple instructions

RESTful architecture

1 What is RESTful

RESTful architecture is the most popular form of Internet software architecture
is proposed by Roy Thomas Fielding in his doctoral dissertation in 2000
is Representational State Transfer acronym, translated as "the presentation layer state transformation"
is all Web applications should comply guidelines architecture
seven HTTP methods: GET, POST, PUT, DELETE , PATCH, HEAD, OPTIONS

2 Interface Specification

Idempotence: No matter how many times you ask, the state of resources is the same.
2.1 GET
safe and idempotent
Gets a
Gets a (cache) when changing
Interface for query class
2.2 POST
unsafe without power and other
examples of the use of server-side management (automatically generated) No. create a resource
to create a child resource
section to update the resource
if it is not modified, but the updated resource (optimistic locking)
Interface for data submission class
2.3 PUT
unsafe but idempotent
create a resource with the instance of Client Management No.
updated resources through alternative ways
, if not modified, the update resource (optimistic locking)
Interface for updating data
2.4 DELETE
unsafe but idempotent
delete resources
Suitable interface uses to delete data
Request returns a response code:

==200== (OK)				- 如果现有资源已被更改
201 (created)				- 如果新资源被创建
202 (accepted)			- 已接受处理请求但尚未完成(异步处理)
301 (Moved Permanently)	- 资源的URI被更新
303 (See Other)			- 其他(如,负载均衡)
==400== (bad request)		- 指代坏请求
==401==						- 未认证
==404== (not found)		- 资源不存在
406 (not acceptable)		- 服务端不支持所需表示
409 (conflict)			- 通用冲突
412(Precondition Failed)	- 前置条件失败(如执行条件更新时的冲突)
415 (unsupported media type)- 接受到的表示不受支持
==500== (internal server error)- 通用错误响应**通常是后台问题
503 (Service Unavailable)	-服务当前无法处理请求
Published 111 original articles · won praise 31 · views 110 000 +

Guess you like

Origin blog.csdn.net/weixin_45678915/article/details/104791320