This is restful, the advantage is to standardize uri, stateless Replace this with https://segmentfault.com/getQuestion.action?id=1010000005831178https://segmentfault.com/getQuestion.action?id=1010000005831178 你会发现: 如果我不想用id做字段名怎么办,前后端一起调一下 如果我不想用getQuestionYou will find:
If I don’t want to use it What should I do if id is used as a field name? Adjust the front-end and back-end together
What if I don’t want to use getQuestion as a method? Adjust the front-end and back-end together
But with restful, there is no such problem. The format is set and the background can be adjusted at will.
Generally, the API of WEB applications will be designed in a restful manner. The things that the API operates are called resources, and the operation method is the request method (GET, POST, DELTE, PUT). Consider each request as an access to resources. Use Some verbs express operations on resources (add, delete, check, modify) /GET/id/{id} //Get resources /POST //Create resources /PUT //Update resources /DELET/id/{ id} //Delete resource
This is restful, the advantage is to standardize uri, stateless
If I don’t want to use it What should I do ifReplace this with
https://segmentfault.com/getQuestion.action?id=1010000005831178
https://segmentfault.com/getQuestion.action?id=1010000005831178
你会发现:
如果我不想用
id
做字段名怎么办,前后端一起调一下如果我不想用
getQuestion
You will find:id
is used as a field name? Adjust the front-end and back-end togetherWhat if I don’t want to use
getQuestion
as a method? Adjust the front-end and back-end togetherBut with restful, there is no such problem. The format is set and the background can be adjusted at will.
🎜That’s all I can say🎜Generally, the API of WEB applications will be designed in a restful manner. The things that the API operates are called resources, and the operation method is the request method (GET, POST, DELTE, PUT).
Consider each request as an access to resources. Use Some verbs express operations on resources (add, delete, check, modify)
/GET/id/{id} //Get resources
/POST //Create resources
/PUT //Update resources
/DELET/id/{ id} //Delete resource
Click here for details
Recommend you to read Ruan Yifeng’s Understanding RESTful Architecture
https://www.zhihu.com/question/28557115
Personally, I feel this is a post that explains restful well. Please focus on Qin Chao’s answer.
Hello, will you do the random push on the WeChat public platform? If it's convenient, add me on QQ? 20998710, or my phone number is 18705947972