Since we have defined the routes elsewhere, we don't need them in the application constructor. Let's remove them.

Here's the new app.rb file. Much cleaner, right?

# weby/app.rb

require_relative './config/routes'

class App
  def call(env)
    headers = { 'Content-Type' => 'text/html' }

    response_html = router.build_response(env['REQUEST_PATH'])

    [200, headers, [response_html]]
  end

  private
    def router
      Router.instance
    end
end

Note that we're using the Router.instance method added by the Singleton module to get the Router's instance.

That's it. Restart the application and give it a try. Everything should work as expected.

We could stop here, but there's one small improvement we can do to make our Router more flexible and powerful.