Conditional wrapper for Rack middleware. This is a port of Plack::Middleware::Conditional.
Add this line to your application's Gemfile:
gem 'rack-conditional'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-conditional
# config.ru
require 'rack_conditional'
use_if proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
Or
# config.ru
require 'rack_conditional'
use Rack::Conditional, proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
Or
# Sinatra
require 'rack_conditional'
class YourApp < Sinatra::Base
use_if proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
end
Or
# Rails
# config/application.rb
require 'rack_conditional'
module YourApp
class Application < Rails::Application
config.middleware.use_if proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
end
end
Bug reports and pull requests are welcome on GitHub at https://github.com/masiuchi/rack-conditional.