Class: Stapler::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/stapler/asset.rb

Constant Summary collapse

FORBIDDEN_PATHS =
%w(.. WEB-INF META-INF)
REWRITE_KEYS =
%w(PATH_INFO REQUEST_PATH REQUEST_URI)

Instance Method Summary collapse

Constructor Details

#initialize(config, path) ⇒ Asset

Returns a new instance of Asset.



10
11
12
13
# File 'lib/stapler/asset.rb', line 10

def initialize(config, path)
  @config = config
  @path = Utils.groom_path(path)
end

Instance Method Details

#response(env) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/stapler/asset.rb', line 15

def response(env)
  if forbidden?
    @config.rack_file.not_found
  else
    @config.rack_file.call(rewrite_env(env))
  end
end