RodaWeb 开发框架

联合创作 · 2023-09-20 11:54

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
浏览 6
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报