Class Rack::LocalStatic
In: app/rack/local_static.rb
Parent: Object

Test custom static asset overrides in development mode. Looks for stylesheets, JavaScripts, etc. in local/public. Handled by web server in production.

Methods

call   new  

Constants

FILE_METHODS = %w(GET HEAD).freeze

Public Class methods

[Source]

    # File app/rack/local_static.rb, line 9
 9:     def initialize(app)
10:       @app = app
11:       @local_file_server = ::Rack::File.new(::File.join(RAILS_ROOT, "local", "public"))
12:     end

Public Instance methods

[Source]

    # File app/rack/local_static.rb, line 14
14:     def call(env)
15:       path        = env['PATH_INFO'].chomp('/')
16:       method      = env['REQUEST_METHOD']
17:       cached_path = (path.empty? ? 'index' : path) + ::ActionController::Base.page_cache_extension
18: 
19:       if FILE_METHODS.include?(method)
20:         if local_file_exist?(path)
21:           return @local_file_server.call(env)
22:         elsif local_file_exist?(cached_path)
23:           env['PATH_INFO'] = cached_path
24:           return @local_file_server.call(env)
25:         end
26:       end
27: 
28:       @app.call(env)
29:     end

[Validate]