Class: Tansu::Static
- Inherits:
-
Object
- Object
- Tansu::Static
- Defined in:
- lib/tansu/static.rb
Constant Summary collapse
- ACCEPT_METHODS =
%w(GET HEAD)
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, root) ⇒ Static
constructor
A new instance of Static.
- #match(path) ⇒ Object
Constructor Details
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tansu/static.rb', line 20 def call(env) method = env['REQUEST_METHOD'] path = env['PATH_INFO'] if ACCEPT_METHODS.include?(method) && path = match(path) env['PATH_INFO'] = path @file_server.(env) else @app.(env) end end |
#match(path) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/tansu/static.rb', line 12 def match(path) return false unless path = verify(path) path = Rack::Utils.clean_path_info(path) match?(path) && path end |