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

As far as I know, according to RESTful guidelines, every url should represent a single resource or a group of resources, and actions should be put as arguments.

Assume we have a group of resources named 'users', and I want to register one more user,
so the api could be:

POST /users HTTP/1.1
Host: www.example.com

username=<username>&password=<password>&email=<email>&age=<age>

Now if I want to unregister a user, then of the unregister api:

Method will still be POST ,
URI will still be /users ,
arguments may be username=<username>&password=<password>&reason=<reason>

In this situation, two apis share the same url and method with different arguments, and I think it's not a good design.

So question is:
What is the good design against this situation, to make the server-end easier to distinguish two different actions on the same resource?

EDIT
I really appreciate @Tim's suggestions and now I want my question to be more generic:
If there are several different updating actions on a resource, and each of the actions takes different combination of arguments, how should I work out RESTful apis now? Thanks a lot. :)


If you register a user by making a POST (create) request, the opposite - unregistering - should be a DELETE request.

Registering

POST /users HTTP/1.1
Host: www.example.com

username=<username>&password=<password>&email=<email>&age=<age>

Unregistering
You can choose to make a request to /users with the username and password (for verification) in the request body

DELETE /users HTTP/1.1
Host: www.example.com

username=<username>&password=<password>&reason=<reason>

Or make a request to /users/<username> with the password (for verification) and a reason (for whatever purpose) in the request body

DELETE /users/<username> HTTP/1.1
Host: www.example.com

&password=<password>&reason=<reason>

I think the latter is better.

链接地址: http://www.djcxy.com/p/7006.html

上一篇: RESTful API:集合URL应该返回什么?

下一篇: RESTful:如何在同一个网址上执行不同的操作?