Class: Oxy::TryStatic
- Inherits:
-
Rack::TryStatic
- Object
- Rack::TryStatic
- Oxy::TryStatic
- Defined in:
- lib/oxy/middleware/try_static.rb
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.
4 5 6 7 8 |
# File 'lib/oxy/middleware/try_static.rb', line 4 def initialize(app, ) @app, @exclude = app, ["_config.yml"] # call superclass super(app, :root => .document_root, :urls => %w[/], :try => [".html", "index.html", "/index.html"]) end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/oxy/middleware/try_static.rb', line 10 def call(env) orig_path = env['PATH_INFO'] found = nil # match requested path against excluded files @exclude.each do |filename| # detour Rack::TryStatic middleware by calling the next middleware in the pipeline break if orig_path.end_with?(filename) && found = @app.call(env) end # pass thru or ask parent middleware to do the job found or super(env) end |