Take you simply understand what is restful api

1. What is restful api:

api is actually an interface, and for restful, first of all we need to know what rest. In fact, it should rest rest described as architecture. It is actually a realization of SOA architecture model. So what is it SOA? In the absence of proposed SOA, in general, it is a server corresponds to a client. For example, a web client need to have a web server, a client app app need to have a server, coupled together between the client and the server. But after proposed SOA architecture, it allows the definition of a unified server and multiple clients to interact, to achieve a decoupling between the client and the server. At this point if multiple clients with the same request, such as app client and web client user name should be modified, then only needs to a single server with a defined interface to send a request, just need the user name information somehow the presentation layer (such as json or xml) can be delivered in the past. Without again before, the server needs to send a request to each of the corresponding. This is what SOA architecture described.
 
So why rest is one kind of SOA architecture to achieve it? Because of the contents of this SOA architecture has been refined in the rest of the specific architecture, implementation. Json example provides the general use as a resource, as the data in the rest of the presentation layer. For example, it specifies what method should be used to perform http corresponding CRUD operations in the rest. For example, it specifies how the url path should be defined in the rest. (You can not use verbs, nouns should be used). rest architecture is to describe some of the elements like that. If we follow the rules of rest, content to design when designing the interface api, then we will be able to meet the rest api design style, referred to as restful api.
 

2, detailed analysis rest:

rest (Representational State Transfer): presentation layer state transitions.
 
analysis:
The presentation layer, the performance of the performance, in fact, can be understood as the surface, referring to the shell resource, this resource represents what looks Yes. For example, it can be json, can be html. Resource refers to a specific thing. For example, a user name and password. The state refers to the state of this particular specific thing resources, specific values, such as user name laowang, so that the status of the user name at this time is laowang. Then convert it actually refers to the transformation that is changing. State transition fact, that is the value of change, change the value.
 
So here some kind of presentation layer presentation layer state transitions should be properly understood by some method of transferring resources to achieve a certain state resources changes , vulgar thing can be said to be achieved by modifying stored in the server json data transfer method using a patch the value of the resource, it can be said that cruder transfer information by using the name of the method patch presentation layer - { "name": "laoliang "} (json) modify the name information stored in the server (originally { "name": "laowang"}) so that it becomes { "name": "laoliang" }.
 
Less complete description is: by using the patch method, passing { "name": "laoliang" } to an interface (API) server, resources for this interface in the database, the original state of the resource information { "name" : "laowang"} modified to transfer over to the new state as a resource json performance layer.
 
This way, then, if there are many clients will need to operate the name information database, then only need to pass to modify the name of the new new status information in some presentation layer as the carrier, the new value into this api Interface, it can be directly modified. It defined like this api interface compatibility of a number of different clients. This is a current trend in software development.
 

3, rest architecture design specific policies:

 
 
References:

Guess you like

Origin www.cnblogs.com/axing-articles/p/11409391.html