rest - RESTful: How to perform different actions on the same url? -


As far as I know, according to the calm guidelines, each URL represents a resource or a group of resources. And actions should be kept as logic

Assume that we have a group of resources called 'user', and if I want to register another user, then the API can be :

  POST / user HTTP / 1.1 host: www.example.com User Name = & lt; Username & gt; And password = & lt; Password & gt; & Amp; Email = & lt; Email & gt; & Amp; Age = & lt; Age & gt;  

Now if I want to unregister a user, then unregistered APIs:

The method is still POST , URI still < Code> / user , the argument can be user name = & lt; Username & gt; And password = & lt; Password & gt; & Amp; Cause = & lt; Reason & gt;

In this situation, two APIs share the same URL and method with different logic, and I think that this is not a good design.

So the question is:
What is the good design against this situation, is it easy to separate the two different actions on the same resource to eliminate the server?

Edit
I appreciate Tim's suggestions and now I want my question to be more general:
If there are many different updates There are work to do, and each action takes different combinations of logic, now how should I work out apis comfortably? Thanks a lot. If you register a user by requesting a post (creation), then the opposite -

Registration

  Post / User HTTP / 1.1 Host: www.example.com Username = & lt; Username & gt; & Amp; Password = & lt; Password & gt; & Amp; Email = & lt; Email & gt; & Amp; Age = & lt; Age & gt;  

Unregister
You choose the option of requesting a username and password (for verification) to / user Can Request Body

  Delete / User HTTP / 1.1 Host: www.example.com Username = & lt; Username & amp; Password = & lt; Password & gt; & Amp; Cause = & lt; Reason & gt;  

Or in the request body (for verification) and for a reason (for whatever purpose) with / user / Request

  Delete / User /  

I think it's better later.


Comments