Tag: 西纳特拉

类中的路由处理程序

我有一个Sinatra应用程序设置,其中大多数逻辑在各种类中执行, post / get路由实例化这些类并调用它们的方法。 我在考虑是否将post / get路由处理程序放在类本身内是一个更好的结构。 无论如何,我想知道是否有可能。 例如: class Example def say_hello “Hello” end get ‘/hello’ do @message = say_hello end end 如果不修改上述内容,Sinatra会说SinatraApplication对象上没有方法say_hello 。