Rack runs an instance of a class that implements the #call
method, but it can also use several other "stand-alone" Rack apps before returning the response to your web-browser by passing the status, headers, and body to each new app, we can stack middleware between the server and the browser to manipulate the details of the request/response cycle. Think of it like a stack.
-
Create a directory called rack_middleware
-
cd
into that directory and create the file app.rb -
We're going to define our base Rack app in app.rb. We just need a class that implements a call method. Add a
MyApp
class that says hello, but doesn't set any headers. We'll add those later.
# app.rb