Sha256: 2d8c785fde00d896087ca3e4026ed4aca2e569bf741e4cfed0b5563795ecd7dd

Contents?: true

Size: 838 Bytes

Versions: 18

Compression:

Stored size: 838 Bytes

Contents

require 'rack/file'

module Hanami
  module Action
    module Rack
      # File to be sent
      #
      # @since 0.4.3
      # @api private
      #
      # @see Hanami::Action::Rack#send_file
      class File
        # The key that returns path info from the Rack env
        #
        # @since 1.0.0
        # @api private
        PATH_INFO = "PATH_INFO".freeze

        # @param path [String,Pathname] file path
        #
        # @since 0.4.3
        # @api private
        def initialize(path, root)
          @file = ::Rack::File.new(root.to_s)
          @path = path.to_s
        end

        # @since 0.4.3
        # @api private
        def call(env)
          env = env.dup
          env[PATH_INFO] = @path

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
hanami-controller-1.3.3 lib/hanami/action/rack/file.rb
hanami-controller-1.3.2 lib/hanami/action/rack/file.rb
hanami-controller-1.3.1 lib/hanami/action/rack/file.rb
hanami-controller-1.3.0 lib/hanami/action/rack/file.rb
hanami-controller-1.3.0.beta1 lib/hanami/action/rack/file.rb
hanami-controller-1.2.0 lib/hanami/action/rack/file.rb
hanami-controller-1.2.0.rc2 lib/hanami/action/rack/file.rb
hanami-controller-1.2.0.rc1 lib/hanami/action/rack/file.rb
hanami-controller-1.2.0.beta2 lib/hanami/action/rack/file.rb
hanami-controller-1.2.0.beta1 lib/hanami/action/rack/file.rb
hanami-controller-1.1.1 lib/hanami/action/rack/file.rb
hanami-controller-1.1.0 lib/hanami/action/rack/file.rb
hanami-controller-1.1.0.rc1 lib/hanami/action/rack/file.rb
hanami-controller-1.1.0.beta3 lib/hanami/action/rack/file.rb
hanami-controller-1.1.0.beta2 lib/hanami/action/rack/file.rb
hanami-controller-1.1.0.beta1 lib/hanami/action/rack/file.rb
hanami-controller-1.0.1 lib/hanami/action/rack/file.rb
hanami-controller-1.0.0 lib/hanami/action/rack/file.rb