Restful style, rest request

This is the back-end small class of the monastery. Each article is shared from

[background introduction] [knowledge analysis] [common problems] [solutions] [coding practice] [extended thinking] [more discussion] [References]

Eight aspects of in-depth analysis of back-end knowledge / skills. This article shares:

[restful style, rest request]

1、 Background introduction

The restful architecture style was originally proposed by Roy T. fielding in his doctoral dissertation in 2000. At the beginning of its birth, it was favored by more and more architects and developers because of its scalability and simplicity. In enterprises, restful API has gradually surpassed soap and become one of the important means to realize SOA. Today, restful architecture style has become the standard configuration of enterprise level services.

2、 Knowledge analysis

Rest is the abbreviation of representative state transfer, which can be translated into "presentation layer state transformation". The biggest characteristics of rest are: resources, unified interface, URI and stateless.

(1) Resource: the so-called "resource" is an entity on the network, or a specific information on the network. It can be a text, a picture, a song, a service, in short, it is a concrete reality. Resources are a set of user oriented data sets with JSON (or other representation) as the carrier. The expression of information by resources tends to the data in the conceptual model

(2) Unified interface: the restful architecture style stipulates that the meta operation of data, i.e. crud, respectively corresponds to the HTTP method: get is used to obtain resources, Post is used to create new resources (or update resources), put is used to update resources, and delete is used to delete resources. In this way, the data operation interface is unified. All data addition, deletion, query and modification can be completed only through the HTTP method.

(3) Uri: a URI (uniform resource locator) can be used to point to a resource. Each URI corresponds to a specific resource. Just get the resource and access its URI. Generally, each resource has at least one URI corresponding to it. The most typical URI is URL.

(4) Stateless: stateless means that all resources can be located through the URL. This location has nothing to do with other resources and will not change due to changes in other resources. As for status and statelessness, for example, to query the salary of employees, if you need to log in to the system, enter the salary query page, and obtain the salary after performing relevant operations, this situation is status, because each operation of querying salary depends on the previous operation, as long as the pre operation is unsuccessful, Subsequent operations cannot be performed; If you can enter a URL to get the salary of the specified employee, this situation is stateless, because getting the salary does not depend on other resources or status. In this case, the employee salary is a resource corresponding to a URL, and the resources can be obtained through the get method in HTTP, which is a typical restful style

3、 What are the characteristics of restful?

(1) Each URI represents a resource and is unique

(2) Some kind of presentation layer of this resource is passed between the client and the server

(3) The client operates the server-side resources through four HTTP verbs to realize "presentation layer state transformation".

(4) Frequently asked questions

The left is wrong and the right is right.

(5) Solution

(6) Expand thinking:

What is restful? What are the differences between rest requests_ Tencent video

"We believe that everyone can become an engineer. From now on, find a senior brother to introduce you, control your learning rhythm, and stop being confused on the way to learning.".

Here is the skill tree In it academy, thousands of senior brothers have found their own learning route here. Learning is transparent and growth is visible. Senior brothers have 1-to-1 free guidance. Come and study with me!

Author: the least shining star link: https://www.jianshu.com/p/f8e89997dc1d Source: the copyright of Jianshu Jianshu belongs to the author. Please contact the author for authorization and indicate the source for any form of reprint.

For more information, you can join the IT communication group 565734203 to discuss and communicate with you

Here is the skill tree · it Academy: a gathering place for beginners to switch to the Internet

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>