class Hanami::Action::Rack::File

File to be sent

@see Hanami::Action::Response#send_file

@since 0.4.3 @api private

Public Class Methods

new(path, root) click to toggle source

@param path [String,Pathname] file path

@since 0.4.3 @api private

# File lib/hanami/action/rack/file.rb, line 23
def initialize(path, root)
  @file = ::Rack::File.new(root.to_s)
  @path = path.to_s
end

Public Instance Methods

call(env) click to toggle source

@since 0.4.3 @api private

# File lib/hanami/action/rack/file.rb, line 30
def call(env)
  env = env.dup
  env[Action::PATH_INFO] = @path

  @file.get(env)
rescue Errno::ENOENT
  [Action::NOT_FOUND, {}, nil]
end