diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-28 18:53:00 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-28 18:53:00 -0300 |
commit | 73aab036eeeb297dc85dc812f54e26aa943f48f7 (patch) | |
tree | 4176d0af72d6975483f4b13924608b5bf106d43d /actionpack/lib/action_dispatch | |
parent | 233ceda594c19331f493ed1436c8c26b5d1aaf1b (diff) | |
parent | 3ff39494cdea67502dbd6465358eca3e14a84d6b (diff) | |
download | rails-73aab036eeeb297dc85dc812f54e26aa943f48f7.tar.gz rails-73aab036eeeb297dc85dc812f54e26aa943f48f7.tar.bz2 rails-73aab036eeeb297dc85dc812f54e26aa943f48f7.zip |
Merge pull request #20017 from eliotsykes/configurable-static-index-filename
config.static_index configures directory Index "index.html" filename
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/static.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index bc5ef1abc9..f20f6ca865 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -13,11 +13,12 @@ module ActionDispatch # located at `public/assets/application.js` if the file exists. If the file # does not exist, a 404 "File not Found" response will be returned. class FileHandler - def initialize(root, cache_control) + def initialize(root, cache_control, index) @root = root.chomp('/') @compiled_root = /^#{Regexp.escape(root)}/ headers = cache_control && { 'Cache-Control' => cache_control } @file_server = ::Rack::File.new(@root, headers) + @index = index end @@ -32,7 +33,7 @@ module ActionDispatch return false unless path.valid_encoding? path = Rack::Utils.clean_path_info path - paths = [path, "#{path}#{ext}", "#{path}/index#{ext}"] + paths = [path, "#{path}#{ext}", "#{path}/#{@index}#{ext}"] if match = paths.detect { |p| path = File.join(@root, p.force_encoding('UTF-8')) @@ -104,9 +105,9 @@ module ActionDispatch # produce a directory traversal using this middleware. Only 'GET' and 'HEAD' # requests will result in a file being returned. class Static - def initialize(app, path, cache_control=nil) + def initialize(app, path, cache_control=nil, index="index") @app = app - @file_handler = FileHandler.new(path, cache_control) + @file_handler = FileHandler.new(path, cache_control, index) end def call(env) |