Skip to content

Rakefire/rack-conditional

 
 

Repository files navigation

Rack::Conditional

Conditional wrapper for Rack middleware. This is a port of Plack::Middleware::Conditional.

Installation

Add this line to your application's Gemfile:

gem 'rack-conditional'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rack-conditional

Usage

# 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

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/masiuchi/rack-conditional.

About

Conditional wrapper for Rack middleware.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 88.5%
  • Shell 11.5%