mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
cache strings in the AST for faster comparison than include?
This commit is contained in:
parent
dd7afdb2dc
commit
af8c54be0a
1 changed files with 3 additions and 6 deletions
|
@ -35,18 +35,15 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
class Static
|
class Static
|
||||||
FILE_METHODS = %w(GET HEAD).freeze
|
|
||||||
|
|
||||||
def initialize(app, path, cache_control=nil)
|
def initialize(app, path, cache_control=nil)
|
||||||
@app = app
|
@app = app
|
||||||
@file_handler = FileHandler.new(path, cache_control)
|
@file_handler = FileHandler.new(path, cache_control)
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
path = env['PATH_INFO'].chomp('/')
|
case env['REQUEST_METHOD']
|
||||||
method = env['REQUEST_METHOD']
|
when 'GET', 'HEAD'
|
||||||
|
path = env['PATH_INFO'].chomp('/')
|
||||||
if FILE_METHODS.include?(method)
|
|
||||||
if match = @file_handler.match?(path)
|
if match = @file_handler.match?(path)
|
||||||
env["PATH_INFO"] = match
|
env["PATH_INFO"] = match
|
||||||
return @file_handler.call(env)
|
return @file_handler.call(env)
|
||||||
|
|
Loading…
Reference in a new issue