【发布时间】:2014-09-29 03:25:43
【问题描述】:
我使用grape来构建我的api网站,我想在我的网站中添加自动使用日志功能,所以我在我的Grape::API类中使用了prepend,我就是这样做的:
module GrapeExtension
def get(paths = ['/'], options = {}, &block)
#add log code here
super
end
end
并在我使用 Grape::API 的地方添加代码,例如
class API < Grape::API
prepend GrapeExtension
#other code
get '/info' do
#function code
end
end
但是当我请求 /info api 时,似乎我在 GrapeExtension 中的代码没有被调用,为什么?
【问题讨论】: