Roda 是一个全新的 Ruby 的 Web 开发框架,通过使用路由树实现更快和 DRY 编码。
示例代码:
# cat config.ru require "roda" class App < Roda use Rack::Session::Cookie, secret: ENV['SECRET'] route do |r| # matches any GET request r.get do # matches GET / r.is "" do r.redirect "/hello" end # matches GET /hello or GET /hello/.* r.on "hello" do # matches GET /hello/world r.is "world" do "Hello world!" end # matches GET /hello r.is do "Hello!" end end end end end run App.app