6 FILE_METHODS
= %w(GET HEAD
).freeze
10 @file_server = ::Rack::File.new(File
.join(RAILS_ROOT
, "public"))
14 path
= env['PATH_INFO'].chomp('/')
15 method
= env['REQUEST_METHOD']
17 if FILE_METHODS
.include?(method
)
19 return @file_server.call(env)
21 cached_path
= directory_exist
?(path
) ? "#{path}/index" : path
22 cached_path
+= ::ActionController::Base.page_cache_extension
24 if file_exist
?(cached_path
)
25 env['PATH_INFO'] = cached_path
26 return @file_server.call(env)
36 full_path
= File
.join(@file_server.root
, ::Rack::Utils.unescape(path
))
37 File
.file
?(full_path
) && File
.readable
?(full_path
)
40 def directory_exist
?(path
)
41 full_path
= File
.join(@file_server.root
, ::Rack::Utils.unescape(path
))
42 File
.directory
?(full_path
) && File
.readable
?(full_path
)