Rails is just a callable. Sinatra is just a callable. So is Roda. This book strips away the magic of Ruby web development, shows you exactly what Rack is doing under the hood, and teaches you to build from first principles. Know your tools. Really know them.
A CloudStreet book.
Read online: https://cloudstreet-dev.github.io/Rack-Roda-and-Ruby/
You've been writing Ruby web applications. You understand routes, controllers, middleware, responses. You know how to use the framework. But do you know what the framework is? Do you know what happens before your code runs, or what "Rack compatibility" actually means, or why every Ruby web framework can be dropped into a config.ru?
This book answers those questions. It starts at the HTTP wire protocol, builds up through the Rack specification, constructs working servers and middleware from scratch, and then examines how Roda—one of the cleanest Ruby web frameworks—sits on top of all of it. By the end, you'll understand not just how to use these tools but why they are the way they are.
The code in this book actually runs. The explanations are accurate. The humor is dry.
- The Rack Spec (It Fits on a Napkin)
- Your First Rack App (No Training Wheels)
- Build a Rack Server from Scratch
- Middleware: Turtles All the Way Down
- Routing Without a Framework (It's Just String Matching)
- Request and Response Objects (DIY Edition)
- Why Rack Alone Isn't Enough
- The Routing Tree (Roda's Big Idea)
- Your First Roda App
- Roda's Plugin System (Opt-In Everything)
- Middleware in Roda
- Testing Roda Apps
You'll need mdBook installed:
cargo install mdbookThen:
git clone https://github.com/cloudstreet-dev/Rack-Roda-and-Ruby
cd Rack-Roda-and-Ruby
mdbook serve --openThis starts a local server at http://localhost:3000 with live reloading.
To build a static copy:
mdbook build
# Output is in ./book/This book is released under CC0 1.0 Universal — public domain. Take it, adapt it, use it in courses, translate it, whatever. Attribution is appreciated but not required.
Thank you to Georgiy Treyvus for coming up with the idea for this book.
This book is part of the CloudStreet series of technical books at github.com/cloudstreet-dev. The series covers practical Ruby, web fundamentals, and the kind of knowledge that makes you genuinely better rather than just more familiar with a particular framework's DSL.