Sha256: 5a224e0f1d10a87d9b0fd3cff449656d89bb2e5338dbac8ca7aa395d4faa6fe7
Contents?: true
Size: 960 Bytes
Versions: 1
Compression:
Stored size: 960 Bytes
Contents
class Rack::App::File::Server attr_reader :namespace, :properties def initialize(root_folder, options={}) require 'rack/file' @raw_root_folder = root_folder @root_folder = Rack::App::Utils.pwd(@raw_root_folder) @relative_file_paths = Dir.glob(File.join(@root_folder,'**','*')).map{|file_path| file_path.sub(@root_folder,'') }.sort_by{|str| str.length }.reverse @rack_file_server = ::Rack::File.new(@root_folder, {}) end def call(env) path_info = clean_path_info(env) @relative_file_paths.each do |relative_file_path| if path_info =~ /#{Regexp.escape(relative_file_path)}$/ env[::Rack::PATH_INFO]= relative_file_path end end @rack_file_server.call(env) end def register_path_params_matcher(*args) end protected def clean_path_info(env) path_info = ::Rack::Utils.unescape(env[::Rack::PATH_INFO]) return clean_path_info = ::Rack::Utils.clean_path_info(path_info) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-app-0.21.0 | lib/rack/app/file/server.rb |