The first step in our web framework is to handle web requests. We set up the basic project structure, then define a Sinatra-style routing DSL allowing us to route different request paths to different blocks of code.
We extend our simple request router to allow variables in the routes, like the variable "username" in "/users/:username". It extracts the variables' values from the requested path and feeds them to the handler block, as in most web frameworks. Regexes are the obvious implementation choice in a language like Ruby. We briefly look at the pitfalls in the regex approach, then implement with a much more straightforward method.
There are a few annoyances with the router that will crop up later. Rather than fixing them during screencasts about the database portion, we fix all three right now. This screencast is optional and doesn't show significant changes to the framework.
We discover SQL injection attacks!
Tests drive our SQL injection bug fix.
We make queries easier and safer.
A line-oriented template language.
The final piece of our web framework.