Just answered a similar question in here .
A practical way of thinking or applying REST as a starting point (at least this works for me) is this:
1) Use only HTTP 'GET / POST / PUT / DELETE as a way to simulate the actions of your domain. As with a database, all your actions are mapped to CURD .
2) The URI / URL should identify only resources. There should never be any action in your URI.
3) The data exchange must be in the body of HTTP messages. Just to simplify discussions, not to simulate the data itself
The tragedy solution looks clean.
Updated for @ Suhas comment address
REST is not a naming convention. It's all about how to think about resources, not about actions when developing a REST API. Always have to think about the "Nonce" resource, as in the URL / URI. You already have all the CURD actions that must be mapped to the domain actions and manage them in the URL.
I like the Tragedian solution, just for the sake of discussion, we can reorganize the Tragedian solution with a similar set of nonce and a different URL pattern to better match the use of different domains. The following may not be the best solution for the domain, but they are equivalent to RESTful.
Remove Membership
- DELETE api / membership / [member-id] /
Get member status
- GET api / membership / [member-id] / status /
Add Membership
- POST api / membership / [member-id] /
Updated to resolve "DisabledMember" as a resource
If you use "PUT DisabledMember" to make "disconnect a member" as suggested by Suhas Then what do the following actions in the "DisabledMember" resource mean?
DELETE DisabledMember -> Activate it again
POST DisabledMember → ??
GET DisabledMember is just one ☺
In this design, it actually “masks” the “disable in resource” action. You can still make her do what you want, but it will not be as useful to me.
Ming chan
source share