全新的 Ruby 的 Web 開發框架:Roda

jopen 11年前發布 | 12K 次閱讀 Roda Ruby開發

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

項目主頁:http://www.baiduhome.net/lib/view/home/1407553136520

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!