Skip to main content
Source Link
sea-rob
  • 6.9k
  • 1
  • 27
  • 48

Since verbs in REST under HTTP are restricted to the HTTP verbs, everything in the URI should be name a noun. So the common trick is to do what you say -- convert the custom verb (sendemail) to a processor noun (emailsender) instead.

At first that seems like a word trick, but it does have some merit. You can then use the "data processing" provision of the POST verb to post commands to your processor. It opens the door to responses like a 202 Accepted if you want to do asynchronous processing.

One thing to watch out for is namespace collision; the processor noun can collide with your identifier namespace. For example:

http://some/site/users/SomeCoolDude

http://some/site/users/emailprocessor

...now you can't have a user named "emailprocessor" because it collides with the processor noun. That may not be a problem if the IDs are ints or UUIDs, but it's something to bear in mind.

...

(And the strict answer is that all the URIs the client uses should come from hypermedia, so the design of the URI should be opaque to the user anyway.)