class Oxy::TryStatic

Public Class Methods

new(app, options) click to toggle source
Calls superclass method
# File lib/oxy/middleware/try_static.rb, line 4
def initialize(app, options)
  @app, @exclude = app, ["_config.yml"]
  # call superclass
  super(app, :root => options.document_root, :urls => %w[/], :try => [".html", "index.html", "/index.html"])
end

Public Instance Methods

call(env) click to toggle source
Calls superclass method
# 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