Do not blindly follow the RESTFUL interface specification

original
2022/02/11 16:17
Reading number 1.3K

Recently, in optimizing the company's interface specification, the original specification document stipulated that the server should strictly follow the RESTFUL style interface, but in practice, many developers did not follow the RESTFUL interface specification. Of course, many of these are implementation level problems, but there is another problem: many business interfaces simply do not adapt to the RESTFUL specification.

I have also read many articles in the past two days, most of which only stay in the theoretical stage when talking about RESTFUL specifications. They only talk about what RESTFUL standards are (URL nominalization, using GET/POST/PUT/DELETE to replace actions in URL, using HTTP status code as the returned CODE, etc.), and rarely talk about how to solve some practical problems in applying RESTFUL in projects, such as login How to define the interfaces of logout, batch addition, complex query, import and export. Generally, there are many API interfaces different from CRUD in actual projects. It is not appropriate to force the adaptation of these API interfaces with RESTFUL standards.

In combination with some articles on the Internet, I summarize some personal opinions on RESTFUL quoted by myself:

1. Do not blindly kneel and lick the RESTFUL standard. The RESTFUL standard is not applicable to all situations.

2. Not busy is never a denial. RESTFUL is applicable in many cases, so in many cases, you should follow some RESTFUL standards. For example, Openapi can try to follow RESTFUL standards in terms of external interface requirements to ensure consistency, but it is unnecessary to fully follow them internally.

3. In case of unadaptability, we can consider adopting the JSON-RPC standard, that is, "post/namespace/resource/action", which is also the naming rule I have seen in many projects, including many large factories.

 

Therefore, any specification and architecture design should be combined with the actual situation and should not be blindly followed.

 

 

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
zero Collection
zero fabulous
 Back to top
Top