Parent

Class Index [+]

Quicksearch

ActionDispatch::Static

Constants

FILE_METHODS

Public Class Methods

new(app, root) click to toggle source
    # File lib/action_dispatch/middleware/static.rb, line 7
 7:     def initialize(app, root)
 8:       @app = app
 9:       @file_server = ::Rack::File.new(root)
10:     end

Public Instance Methods

call(env) click to toggle source
    # File lib/action_dispatch/middleware/static.rb, line 12
12:     def call(env)
13:       path   = env['PATH_INFO'].chomp('/')
14:       method = env['REQUEST_METHOD']
15: 
16:       if FILE_METHODS.include?(method)
17:         if file_exist?(path)
18:           return @file_server.call(env)
19:         else
20:           cached_path = directory_exist?(path) ? "#{path}/index" : path
21:           cached_path += ::ActionController::Base.page_cache_extension
22: 
23:           if file_exist?(cached_path)
24:             env['PATH_INFO'] = cached_path
25:             return @file_server.call(env)
26:           end
27:         end
28:       end
29: 
30:       @app.call(env)
31:     end

Private Instance Methods

directory_exist?(path) click to toggle source
    # File lib/action_dispatch/middleware/static.rb, line 39
39:       def directory_exist?(path)
40:         full_path = File.join(@file_server.root, ::Rack::Utils.unescape(path))
41:         File.directory?(full_path) && File.readable?(full_path)
42:       end
file_exist?(path) click to toggle source
    # File lib/action_dispatch/middleware/static.rb, line 34
34:       def file_exist?(path)
35:         full_path = File.join(@file_server.root, ::Rack::Utils.unescape(path))
36:         File.file?(full_path) && File.readable?(full_path)
37:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.