Method: Rack::Adapter::Rails#call

Defined in:
lib/rack/adapter/rails.rb

#call(env) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rack/adapter/rails.rb', line 65

def call(env)
  path        = env['PATH_INFO'].chomp('/')
  method      = env['REQUEST_METHOD']
  cached_path = (path.empty? ? 'index' : path) + ActionController::Base.page_cache_extension
  
  if FILE_METHODS.include?(method)
    if file_exist?(path)              # Serve the file if it's there
      return serve_file(env)
    elsif file_exist?(cached_path)    # Serve the page cache if it's there
      env['PATH_INFO'] = cached_path
      return serve_file(env)
    end
  end
  
  # No static file, let Rails handle it
  serve_rails(env)
end