Defining Custom HTTP Methods

Earlier this week I saw the following comment:

HTTP defines a limited set of verbs, but APIs should be allowed to define their own verbs. Oftentimes, "get" or "post" or "delete" simply isn’t what you really. Then one of the following usually happens – either we use an HTTP verb that doesn’t accurately describe what’s happening, or we put the real verb somewhere else (e.g. in the URI or JSON body).

It is true that HTTP defines a small set of verbs, or ‘methods’ in the words of the standard. But developers can define their own, yet I rarely see anyone take advantage of this. So today I will show you how and why you may wish to do so.

Note: I’m not going to show any actual code in this article, under the assumption that you know how to use the language and web framework of your choice in order to return HTTP headers in requests, handle requests based on specific HTTP methods, and so on.

Continue reading “Defining Custom HTTP Methods”