Rack - Ruby Web server 接口
最小的 Rack
Proc.new { |env|
[
200,
{"Content-Type" => 'text/plain'},
["Hello, world"]
]
}使用举例
再举个例子:
再使用举例
最后更新于
Proc.new { |env|
[
200,
{"Content-Type" => 'text/plain'},
["Hello, world"]
]
}最后更新于
# my_rack_app.rb
require 'rack'
app = Proc.new do |env|
['200', {'Content-Type' => 'text/html'}, ['A example rack app.']]
end
Rack::Handler::WEBrick.run app# config.ru
run Proc.new { |env| ['200', {'Content-Type' => 'text/html'}, ['get rack\'d']] }class YourRack
def initialize(app)
@app = app
end
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
end
endrequire 'rack'
require 'rack/contrib'
use Rack::Profiler if ENV['RACK_ENV'] == 'development'
use Rack::ETag
use Rack::MailExceptions
run theapp