Class: Mack::Static

Inherits:
Rack::Static show all
Defined in:
lib/mack/utils/static.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Rack::Static

#initialize

Constructor Details

This class inherits a constructor from Rack::Static

Instance Method Details

#call(env) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mack/utils/static.rb', line 4

def call(env)
  path = env["PATH_INFO"]
  can_serve = @urls.any? { |url| path.index(url) == 0 }

  if can_serve
    res = @file_server.call(env)
    # This is the BIG difference between Mack::Static and Rack::Static:
    return @app.call(env) if res.nil? || res[0] == 404
    return res
  else
    return @app.call(env)
  end
end