$: << File.dirname(__FILE__)
module TestComponent
class Application
def initialize
puts "Application initialized"
end
# Rack requires object being run to have a `call` method which returns
# an Array that includes the status code, http headers and a content response
def call(env)
[200, { 'Content-Type' => 'text/html' }, ['Hello World!']]
end
end
end
4. Class based Rack server - config.ru
$: << File.dirname(__FILE__)
require 'app/app'
run TestComponent::Application.new