The front-end surface is REST, RESTful architecture (one sentence summarizes RESTful)

REST, RESTful architecture (summarizing RESTful in one sentence)

REST

REST is the abbreviation of Representational State Transfer, translated as " presentation layer state transfer" .

If an architecture conforms to REST principles, then it is called a RESTful architecture.

Resources

Several key points of resources and URLs:

  1. A resource is an entity on the network, or a specific piece of information on the network;
  2. Use a URL (Uniform Resource Locator) to point to the resource, and each resource corresponds to a specific URL;
  3. To get a resource, just visit the URL of the resource. That is, the URL is the address or unique identifier of each resource.

In other words, surfing the Internet is to interact with a series of resources on the Internet, that is, to constantly visit the URL corresponding to each resource.

Note: As
mentioned above, REST is "presentation layer state transfer". In fact, the presentation layer is the presentation layer of "resources". So what REST should say is the transformation of the state of the presentation layer of resources.

Representation

The specific form of "resources" Resources is called the representation of resources.

For example:
For example, a piece of text can be expressed in txt format or HTML format, etc.;
pictures can be expressed in JPG format or in PNG format.

Note:
URL only represents the entity of the resource, not the form of the resource, nor the presentation layer of the resource.

State Transfer

Simply put: Internet access is an interactive process between the client and the server. In this interactive process, if the client wants to access Resources, it involves changes in resources, data, and status.

First of all, the HTTP protocol is a stateless protocol, that is, all state is stored on the server instead of on the client. Then the client accesses certain resources through the HTTP protocol, which will inevitably cause the state of the server-side resources to be transformed. The state transformation of resources is reflected in the presentation layer of resources. That is, the presentation layer state of the resources on the server side is transformed.

Furthermore, the client interacts with the server using the HTTP protocol. There are four verbs in the HTTP protocol: GET, POST, PUT, and DELETE.

  1. GET: Get resources
  2. POST: New resource (or update resource)
  3. PUT: Update resources
  4. DELETE: delete resources

to sum up

REST is Representational State Transfer, that is, the state transfer of the presentation layer.
An architecture that conforms to REST principles is called a RESTful architecture.

URL location resources Resources, that is, access to URL to obtain resources.

The state transformation of the presentation layer is actually the state transformation of the presentation layer of the resource .

The client accesses the resource, and the state of the presentation layer of the resource on the server is transformed.

The client uses the four HTTP verbs, GET, POST, PUT, and DELETE, to operate on server-side resources to achieve the transformation of the resource's presentation layer state.

It is summarized as follows:

  1. URL location resource
  2. The interaction between the client and the server causes the state transition of the presentation layer of the resource
  3. The client uses 4 HTTP verbs: GET, POST, PUT, and DELETE to operate on the resources on the server side to realize the " presentation layer state transfer" of the resources on the server side

Guess you like

Origin blog.csdn.net/qq_43263320/article/details/114380831