HanamiRuby 的 Web 框架

联合创作 · 2023-09-20

Hanami 是一个全栈的 Ruby 的 Web 框架。是一个非常精简、用于单一用途的库。

Hanami 包含如下组件:

目录结构:

% tree apps/web
apps/web
├── application.rb
├── assets
│   ├── favicon.ico
│   ├── images
│   ├── javascripts
│   └── stylesheets
├── config
│   └── routes.rb
├── controllers
├── templates
│   └── application.html.erb
└── views
    └── application_layout.rb

8 directories, 5 files

示例代码:

# apps/web/controllers/dashboard/index.rbmodule Web::Controllers::Dashboard
  class Index
    include Web::Action

    def initialize(greeting: Greeting.new)
      @greeting = greeting
    end

    def call(params)
      self.body = @greeting.message
    end
  endend
浏览 3
点赞
评论
收藏
分享

手机扫一扫分享

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

手机扫一扫分享

编辑
举报