Class: ActionDispatch::Static

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/middleware/static.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, path, cache_control = nil) ⇒ Static

Returns a new instance of Static



69
70
71
72
# File 'actionpack/lib/action_dispatch/middleware/static.rb', line 69

def initialize(app, path, cache_control=nil)
  @app = app
  @file_handler = FileHandler.new(path, cache_control)
end

Instance Method Details

#call(env) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'actionpack/lib/action_dispatch/middleware/static.rb', line 74

def call(env)
  case env['REQUEST_METHOD']
  when 'GET', 'HEAD'
    path = env['PATH_INFO'].chomp('/')
    if match = @file_handler.match?(path)
      env["PATH_INFO"] = match
      return @file_handler.call(env)
    end
  end

  @app.call(env)
end