Simple Explanation of rack middleware?

_config.yml

Simple Explanation: without anything technical:

What is it like? To what can I compare it to? Well you can think of rails middleware as something like this:

Do you remember the game: “Chinese whispers” that you played as a kid? You want to tell your friend - who sits at the other end of the line, a special message. but you can’t tell him or her directly: you must pass your message from person to person until it finally reaches him or her.

But more often that not you’ll find that changes to the message happen as it goes through the chain, till it reaches the end point. For example:

  1. Originator: “You will always remember this as the day that you almost caught Captain Jack Sparrow.”
  2. Person 1 - passes on: “You will always remember the day that you almost caught Captain Jack Sparrow.”
  3. Person 2 - passes on: “You will remember the day that you almost caught Captain Jack Sparrow.”
  4. Person 3 - passes on: “You will remember the day you caught Captain Jack Sparrow.”
  5. Person 4 - passes on: “You will remember Captain Jack Sparrow.”
  6. Final Message received: “Remember Captain Jack Sparrow”

Middleware are basically the people in between you, the originator of the message, and the final message that was recieved: notice how they can change or filter the message?

That’s kinda what middleware is all about in a nutshell - well that’s the basic concept. The are further requirements that need to be followed for it to be “rack” based but I think you should get the general gist of what’s going on. Now if you read the more technical articles that should make more sense to you.

Hope this helps.

Written on June 27, 2017