HTTP request Methods

HTTP request Methods

·

2 min read

As a beginner many years ago, I kept seeing these words:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE

But what do these HTTP request types mean? Let's explain this with a simple analogy.

Let's say you own an Italian restaurant. Flag of Italy

You have a staff that consists of kitchen personnel and waiters. Customers can come in to sit down and order some of your delicious food!

Making orders can be done by choosing from the menu card.

GET

You walk into the restaurant and sit down. Let's eat! Fork and knife with plate

You call the waiter and ask him to bring the menu for you. He brings you the menu and you have the proper information that you needed to order your food!

GET is used to request data from a specified resource

POST

An employee comes up with an awesome new recipe. The owner of the restaurant likes it and says:

Alright, let's add this to our menu, so our customers can now order this new recipe!

POST is (mostly) used to send data to a server and store it.

PATCH

A customer notices a grammar mistake on the menu and notifies the waiter.

The budget is currently tight and there is no money to replace all the menu cards, so they use correction tape to fix the typo.

PATCH supplies a set of instructions to modify a resource.

PUT

Three months later, a customer finds another typo on the menu. This has gotten out of hand. Time to change the whole menu.

New menu cards are ordered and replace the old ones, fixing all the typos.

PUT supplies a modified version of a resource and replaces the original.

DELETE

The owner of the restaurant decides that his physical business isn't viable anymore and moves to order only.

The menu cards are not needed anymore so he throws them away.

DELETE is for deleting a resource.

A wonderful piece by Raf Rasenberg.