I'm trying to learn Roda and am having a bit of trouble moving into a style of separating out routes into their own files. I got the simple app from the Roda README running and am working on that as a base.
I am trying to use the multi_route plugin as well. So far, this is my setup:
config.ru
require 'rack/unreloader'
Unreloader = Rack::Unreloader.new { Greeter }
require 'roda'
Unreloader.require './backend.rb'
run Unreloader
backend.rb
require 'roda'
# Class Roda app
class Greeter < Roda
puts 'hey'
plugin :multi_route
puts 'hey hey hey'
route(&:multi_route)
end
Dir['./routes/*.rb'].each { |f| require f }
index.rb
Greeter.route '/' do |r|
r.redirect 'hello'
end
hello.rb
Greeter.route '/hello' do |r|
r.on 'hello' do
puts 'hello'
@greeting = 'helloooooooo'
r.get 'world' do
@greeting = 'hola'
"#{@greeting} world!"
end
r.is do
r.get do
"#{@greeting}!"
end
r.post do
puts "Someone said #{@greeting}!"
r.redirect
end
end
end
end
So, now when I do my rackup config.ru and go to localhost:9292 in my browser, I get a blank page and 404s in the console. What is out of place? I suspect I'm not using multi_route correctly, but I'm not sure.