Object
# File lib/rack/adapter/rails.rb, line 18
18: def initialize(options={})
19: @root = options[:root] || Dir.pwd
20: @env = options[:environment] || 'development'
21: @prefix = options[:prefix]
22:
23: load_application
24:
25: @rails_app = if rack_based?
26: ActionController::Dispatcher.new
27: else
28: CgiApp.new
29: end
30:
31: @file_app = Rack::File.new(::File.join(RAILS_ROOT, "public"))
32: end
# File lib/rack/adapter/rails.rb, line 59
59: def call(env)
60: path = env['PATH_INFO'].chomp('/')
61: method = env['REQUEST_METHOD']
62: cached_path = (path.empty? ? 'index' : path) + ActionController::Base.page_cache_extension
63:
64: if FILE_METHODS.include?(method)
65: if file_exist?(path) # Serve the file if it's there
66: return @file_app.call(env)
67: elsif file_exist?(cached_path) # Serve the page cache if it's there
68: env['PATH_INFO'] = cached_path
69: return @file_app.call(env)
70: end
71: end
72:
73: # No static file, let Rails handle it
74: @rails_app.call(env)
75: end
# File lib/rack/adapter/rails.rb, line 54
54: def file_exist?(path)
55: full_path = ::File.join(@file_app.root, Utils.unescape(path))
56: ::File.file?(full_path) && ::File.readable_real?(full_path)
57: end
# File lib/rack/adapter/rails.rb, line 39
39: def load_application
40: ENV['RAILS_ENV'] = @env
41:
42: require "#{@root}/config/environment"
43: require 'dispatcher'
44:
45: if @prefix
46: if ActionController::Base.respond_to?(:relative_url_root=)
47: ActionController::Base.relative_url_root = @prefix # Rails 2.1.1
48: else
49: ActionController::AbstractRequest.relative_url_root = @prefix
50: end
51: end
52: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.