Removing a particular middleware from Sinatra based Ruby application

From time to time, you may want to remove a particular middleware from your Sinatra application. Normally I would not recommend this, but when you test stuff and play around there might be no other way. It is also useful when a middleware contains bugs that make it unusable in your particular case. Removing it is really easy. Only thing you need to know is the name of the middleware you want to remove:

Sidekiq::Web.instance_variable_get(:@middleware).delete_if do |middleware|
  middleware.first == Rack::Protection # Or any other middleware name
end
20
Mar 2016
POSTED BY
POSTED IN Ruby Software
DISCUSSION 0 Comments