cache strings in the AST for faster comparison than include?

This commit is contained in:
Aaron Patterson 2011-05-02 17:05:20 -07:00
parent dd7afdb2dc
commit af8c54be0a

@ -35,18 +35,15 @@ def ext
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)