Rack middleware is one of those things that's actually very simple. We'll see how we can implement the basic concept in just a few lines of code. But because of sparse documentation and an unclear API, getting started with Rack middleware is a confusing endeavor for anyone new to the concept.
But fear not. We're going to boil all the core concepts of the Rack middleware stack into an easy to run and understand code example. Along the way, we'll get some insight into what's going on under the hood.
Like many web developers, I got my start programming on the web with PHP. When you're working with PHP it's obvious how to start from scratch on a simple web app. Get out a
.php file, two cups of HTML, a pinch of
<?php ?> tags. Throw it in the oven and you're done.
With Ruby, things aren't so obvious. Virtually every Rubyist gets his or her start with a framework. You go along happily pecking out one line of code after another, never understanding what lies beneath the surface.
A few years ago when I was working for a university and we were rolling out CAS authentication for our apps. I headed to the internet to read up on anything I could find about CAS. Unfortunately, what I did find was a jumbled and overly complex mess of documentation. So, for the sake of those who will come after me, I'm going to do my best to explain, in as simple terms as possible, how CAS client authentication works. I'm assuming you have at least a basic understanding of HTTP requests, responses and cookies.
As I write this, I'm sitting at home in the dark. Sweat beads forming on my forehead as the 90° weather outside suddenly discovers there's no air conditioning to keep it at bay. Yes, I am the victim of a power outage. An all too present reminder that downtime happens.
Downtime is an unfortunate reality of working in IT. Whether it's planned or not, even the likes of Amazon and Google can't be up 100% of the time and neither can you.