how does a middleware get deleted?

旧城冷巷雨未停 提交于 2019-12-05 14:45:33

Why not just have something like the following?

group :production do
  gem "rack-timeout"
end

In theory, the middleware deletion in the initializer should take care of the problem after a server restart, assuming you're talking about putting something in config/initializers/.


Did a little more experimentation and dropped this into config/initializers/rack-timeout.rb:

if Rails.env.production?
  Rack::Timeout.timeout = 0.5
else
  Rails.configuration.middleware.delete Rack::Timeout
end

And this in a scaffolded controller:

sleep 1

Everything seemed cool after I restarted the dev server (no timeouts in sight :D). So, maybe just a bad variable.

I still think using a production-only group is the better solution.

Ran with Rails 3.2.2 with ruby 1.9.2-p290 on OSX.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!