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
|
||||
|
||||
class Static
|
||||
FILE_METHODS = %w(GET HEAD).freeze
|
||||
|
||||
def initialize(app, path, cache_control=nil)
|
||||
@app = app
|
||||
@file_handler = FileHandler.new(path, cache_control)
|
||||
end
|
||||
|
||||
def call(env)
|
||||
path = env['PATH_INFO'].chomp('/')
|
||||
method = env['REQUEST_METHOD']
|
||||
|
||||
if FILE_METHODS.include?(method)
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue