Rack 通过句柄的机制来支持应用服务器
pry(main)> Rack::Handler.constants
=> [:CGI,
:FastCGI,
:Mongrel,
:EventedMongrel,
:SwiftipliedMongrel,
:WEBrick,
:LSWS,
:SCGI,
:Thin]
应用服务器也可以通过包含 Rack handler 来支持 Rack 接口 • Ebb • Fuzed • Glassfish v3 • Phusion Passenger (which is mod_rack for Apache and for nginx) • Rainbows! • Unicorn • Zbatery
Rack 是什么?
A Rack application is an Ruby object (not a class) that responds to call. It takes exactly one argument, the environment and returns an Array of exactly three values: e status, the headers, and the body.
It takes exactly one argument, the environment and returns an Array of exactly three values: e status, the headers, and the body.
来个超级简单的例子:
rack_app = lambda{|env| [200,{},["hello from lambda"]]}
Rack::Handler::WEBrick.run rack_app ,:Port=>3000
这个时候到浏览器输入http://localhost:3000,那么将得到 hello from lambda
不知道你现在对 Rack 是什么认识?