我有一个框架Padrino (0.10.7)项目,几乎没有代码。我正在尝试在boot.rb中插入一个中间件:
##
# Add your after (RE)load hooks here
#
Padrino.after_load do
DataMapper.finalize
Padrino.use MyClass #Line (1) added by me
end
Padrino.load!在MyClass中,
class MyClass
def initialize arg
@arg = arg
end
end如果我尝试使用瘦服务器(1.5.x),我会得到这个异常(仅当我插入中间件时):
Uncaught exception: app required同样适用于内置的webrick。
有没有办法让它和thin一起工作?
发布于 2013-01-10 17:02:08
算了,找到了。基本上,您还需要定义call (env)方法,否则它甚至不会启动服务器。这是中间件的最低要求:
class MyClass
def initialize app
@app = app
end
def call env
@app.call env
end
endhttps://stackoverflow.com/questions/14251507
复制相似问题