Interesting
Coming from PHP I am used to "middlewares" being a framework-concern IIRC
I remember some version of Zend framework was built completely on the idea of middlewares up until the middleware at the core that held the "business logic"
https://www.akshaykhot.com/definitive-guide-to-rack/
The Definitive Guide to Rack for Rails Developers

The word Rack actually refers to two things: a protocol and a gem. This article explains pretty much everything you need to know about Rack as a Rails developer. We will start by understanding the problem Rack solves and move to more advanced concepts like middleware and the Rack DSL.

Akshay's Blog