Class: Lurker::Server::TryStatic
- Inherits:
-
Object
- Object
- Lurker::Server::TryStatic
- Defined in:
- lib/lurker/server.rb
Overview
fixed rack_contrib implementation
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options) ⇒ TryStatic
constructor
A new instance of TryStatic.
Constructor Details
#initialize(app, options) ⇒ TryStatic
Returns a new instance of TryStatic.
8 9 10 11 12 13 14 |
# File 'lib/lurker/server.rb', line 8 def initialize(app, ) @app = app @try = ['', *.delete(:try)] @static = ::Rack::Static.new( proc { [404, {}, []] }, # HERE proc, not lambda ) end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/lurker/server.rb', line 16 def call(env) orig_path = env['PATH_INFO'] found = nil @try.each do |path| resp = @static.call(env.merge!('PATH_INFO' => orig_path + path)) break if 404 != resp[0] && found = resp end found or @app.call(env.merge!('PATH_INFO' => orig_path)) end |