Created
June 4, 2011 15:24
-
-
Save bbttxu/1007976 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rack' | |
require 'rack-legacy' | |
require 'rack-rewrite' | |
require 'rack/tidy' | |
# flipped, returning late rather than first to get around LocalJumpError | |
# http://blog.jayfields.com/2007/03/ruby-localjumperror-workaround.html#4379157363252949431 | |
INDEXES = ['index.cgi', 'index.php', 'index.html'] | |
use Rack::Rewrite do | |
rewrite %r{(.*/$)}, lambda {|match, rack_env| | |
served_file = rack_env['PATH_INFO'] | |
INDEXES.each do |index| | |
if File.exists?(File.join(Dir.getwd, rack_env['PATH_INFO'], index)) | |
served_file = rack_env['PATH_INFO'] + index | |
end | |
end | |
served_file | |
} | |
end | |
use Rack::Tidy | |
use Rack::Legacy::Php, Dir.getwd | |
use Rack::Legacy::Cgi, Dir.getwd | |
run Rack::File.new Dir.getwd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment