Class: ActionDispatch::Static
- Inherits:
-
Object
- Object
- ActionDispatch::Static
- Defined in:
- actionpack/lib/action_dispatch/middleware/static.rb
Constant Summary
- FILE_METHODS =
%w(GET HEAD).freeze
Instance Method Summary (collapse)
- - (Object) call(env)
-
- (Static) initialize(app, roots)
constructor
A new instance of Static.
Constructor Details
- (Static) initialize(app, roots)
A new instance of Static
42 43 44 45 |
# File 'actionpack/lib/action_dispatch/middleware/static.rb', line 42 def initialize(app, roots) @app = app @file_handlers = create_file_handlers(roots) end |
Instance Method Details
- (Object) call(env)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'actionpack/lib/action_dispatch/middleware/static.rb', line 47 def call(env) path = env['PATH_INFO'].chomp('/') method = env['REQUEST_METHOD'] if FILE_METHODS.include?(method) @file_handlers.each do |file_handler| if match = file_handler.match?(path) env["PATH_INFO"] = match return file_handler.call(env) end end end @app.call(env) end |