diff options
author | Mark Turner <mark@amerine.net> | 2010-09-10 23:00:03 -0700 |
---|---|---|
committer | raggi <jftucker@gmail.com> | 2010-10-03 13:24:08 -0300 |
commit | 6e873c7521f47d43af7a8350705121e222eca0e5 (patch) | |
tree | c0eb93ef3ecaaf6e19c64cfa62b8ab4dae9a5884 /lib/rack | |
parent | 294c1853ad5c6a0286221f7b2046ec7900f70775 (diff) | |
download | rack-6e873c7521f47d43af7a8350705121e222eca0e5.tar.gz |
Added the ability to pass a hash of route to file mappings to Rack::Static
Signed-off-by: raggi <jftucker@gmail.com>
Diffstat (limited to 'lib/rack')
-rw-r--r-- | lib/rack/static.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/rack/static.rb b/lib/rack/static.rb index 168e8f83..e8c93373 100644 --- a/lib/rack/static.rb +++ b/lib/rack/static.rb @@ -25,14 +25,21 @@ module Rack def call(env) path = env["PATH_INFO"] - can_serve = @urls.any? { |url| path.index(url) == 0 } - + + unless @urls.kind_of? Hash + can_serve = @urls.any? { |url| path.index(url) == 0 } + else + can_serve = @urls.key? path + end + if can_serve + env["PATH_INFO"] = @urls[path] if @urls.kind_of? Hash @file_server.call(env) else @app.call(env) end end + end end |