In fact, no matter what framework is used, as long as the use of ajax is not considered, then the URL cannot completely follow RESTful, but this does not prevent the design of a set of URL specifications that are as RESTful as possible and practical.
If you use Spring, try to map requests to specific methods instead of writing branches in methods.
In this case, the following specification can be used
request method action | Project specific action | Request button specified action | URL | class method | Exam preparation |
GET | /posts | index | Obtaining a list of resources | ||
GET | /posts/create | create | Create an initialization page | ||
POST | /posts | store | create | ||
GET | /posts/{id} | show | Show specific resources | ||
GET | /posts/{id} | edit | Modify the initialization page | ||
PUT | _method=put mock, actually post | /posts/{id} | update | Modify a specific resource | |
DELETE | _method=delete mock, actually post | /posts/{id} | destroy | Delete a specific resource, which can be combined with multiple deletes below | |
GET | /posts?key1=xxx&key2=xxx | index | retrieve. This can actually be combined with the resource acquisition list. | ||
DELETE | _method=delete mock, actually post | /posts | destroy | Delete selected resources | |
POST | The submit button specifies the action | /posts /posts/{id} |
Action name | Work on a set of resources or a specific resource. Such as retrieval in the form of a post, or individual processing within a specific resource. |
In fact, the purpose of the design is that the processing actions are designed with the following priorities
Request Method Actions > Item Specified Actions > Request Button Specified Actions.