In chapter 2 of Rebuilding Rails, you go through the process of routing requests through a controller as opposed to returning the same response to every request. Here are some of the important parts:

Intro to routing

A request comes to your server, and Rack sends that request through to your application code. Skates needs to route the request in order for the correct page to be rendered for a given request.

```ruby skates/lib/skates.rb

require “skates/version” require “skates/routing”

module Skates class Application def call(env) klass, action = get_controller_and_action(env) controller = text = controller.send(action) [200, {‘Content-Type’ => ‘text/html’}, [text]] end end

class Controller def initialize(env) @env = env end

  def env
  end   end end
Similar to [last post](), you need a <code>call</code> method inside the <code>Application</code> class. This time, it's inside the gem's main module, which will be included in the Gemfile of your app. Instead of just returning the same response every time, Skates is now going to look for a controller and action. In line 7, <code>klass</code> and <code>action</code> are both set to the return value of the <code>get_controller_and_action</code> method, which lives in the the routing file. Next, the controller that is returned is initialized with <code></code>. That controller then uses <code>send</code>, a Ruby method that simply invokes whatever method is passed to it as an argument. In this case, it invokes the action within the controller. Then, a response is returned with the return value of that action. Although this is a simple example, it gives you a good look at how Rails actually finds and invokes the correct controller action that's specified in the routes file.

Then, you define a class called <code>Controller</code>, which the controllers in your app will inherit from. It's the equivalent to <code>ActionController::Base</code> in Rails. This class just initializes with the <code>env</code> hash.

For this example, that's all that needs to be done on the framework's end. Now all that's left to do is write a controller in whatever app that uses the framework. The new controller inherits from the Controller class in Skates:

```ruby my_controller.rb

class MyController < Skates::Controller
  def home_page
    "Hello, world."