Skip to content

samsm/rack-if

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rack::If

Use or don’t use rack apps based on a variety of environment variables.

Use

gem install rackif

Example (in your config.ru):

require 'rackif'
use Rack::If do
  if path == '/protected' && method != 'GET'
    use Rack::Auth::Basic, "Rack::If Example" do |username, password|
      'secret' == password
    end
  end
end

run MyApp.new # when above matches, this is protected

Configuration

Rack::If block Shortcut methods for path, method, user_agent, host, port, query_string, http_accept, and http_accept_encoding are available, anything else is available at env.

Example:

use Rack::If do
  unless env['rack.session']['verified_identity']
    use EasyRackOpenID
  end
end

Copyright © 2009 Sam Schenkman-Moore, David Dollar. See LICENSE for details.

About

Conditionally use Rack apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages