GOAL: To make our Rack-compliant web application talk to Puma application server.

At this point, we have the Puma application server, and we also have our application app.rb.

The only thing missing is the glue that connects the two.

How does Puma pass the incoming request to our application?

The answer is a rackup file, which is just a Ruby file with .ru extension. All Rails apps use this file. When you create a new Rails app, it's generated for you.

When we launch Puma (next step) without any arguments, it looks for this rackup file called config.ru in the current directory. Check out the Puma documentation to learn more.

So let's add a config.ru file in the weby directory.

touch config.ru

Add the following code to this file. It loads the rack gem and also loads our application.

require 'rack'
require_relative './app'

run App.new

The run method is provided by the Rack gem that we installed earlier. It takes a Ruby object as an argument and invokes the call method on it.

Since the App class has a call method, Rack can run it just fine.

At this stage, you should have the following structure in your project directory.

explorer.png

We have the final piece of the puzzle. The only thing remaining is running the application!