具体rack是啥,middleware是啥,metal是啥就不说了!
看看自定义rack吧:
在lib下面定义一个这样的文件:内容如下:
class ModelAccessArea
def initialize(app)
@app = app
end
def call(env)
if env["PATH_INFO"] =~ /^\/poller/
[200, {"Content-Type" => "text/html"}, "Hello, World"]
else
[404, {"Content-Type" => "text/html"}, "Not Found"]
end
end
end
在initializers中定义一个文件:内容如下:
YourAppName::Application.config.middleware.use ::ModelAccessArea
这样一来的话:
http://localhost:3000/poller
显示 Hello, World
其他请求均为not found!