提交 af8c54be 编写于 作者: A Aaron Patterson

cache strings in the AST for faster comparison than include?

上级 dd7afdb2
...@@ -35,18 +35,15 @@ def ext ...@@ -35,18 +35,15 @@ def ext
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册