Project

rack-if

0.0
No commit activity in last 3 years
No release in over 3 years
Use or don't use Rack apps based on a variety of environment factors.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

> 1
 Project Readme

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.