O'Reilly logo

Crafting Rails 4 Applications, 2nd Edition by José Valim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

images/7_stacks.png
Figure 15. The middleware stacks involved in a request to an action in a Rails controller ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required