Middleware Stacks
Although web-server adapters and the Rack application API revolutionized the way Ruby web frameworks are developed, you’re probably more familiar with another term related to Rack: middleware.
A middleware wraps around a Rack application. It lets us manipulate both the request sent down to the application and the response the application returns. By piling up many middleware before an application, we create a middleware stack. Any request to an action in a Rails controller passes through three middleware stacks, as the following figure shows.
Get Crafting Rails 4 Applications, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.