Sha256: 32c597407d3a230c030c0a99882989d56d652fd53c854215a48f61e587e5f3c6

Contents?: true

Size: 818 Bytes

Versions: 14

Compression:

Stored size: 818 Bytes

Contents

# frozen_string_literal: true

require "rack/file"

module Hanami
  class Action
    # Rack extensions for actions.
    #
    # @api private
    # @since 0.4.3
    module Rack
      # File to be sent
      #
      # @see Hanami::Action::Response#send_file
      #
      # @since 0.4.3
      # @api private
      class File
        # @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[Action::PATH_INFO] = @path

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hanami-controller-2.2.0 lib/hanami/action/rack/file.rb
hanami-controller-2.2.0.rc1 lib/hanami/action/rack/file.rb
hanami-controller-2.2.0.beta2 lib/hanami/action/rack/file.rb
hanami-controller-2.2.0.beta1 lib/hanami/action/rack/file.rb
hanami-controller-2.1.0 lib/hanami/action/rack/file.rb
hanami-controller-2.1.0.rc3 lib/hanami/action/rack/file.rb
hanami-controller-2.1.0.rc2 lib/hanami/action/rack/file.rb
hanami-controller-2.1.0.rc1 lib/hanami/action/rack/file.rb
hanami-controller-2.1.0.beta2 lib/hanami/action/rack/file.rb
hanami-controller-2.1.0.beta1 lib/hanami/action/rack/file.rb
hanami-controller-2.0.2 lib/hanami/action/rack/file.rb
hanami-controller-2.0.1 lib/hanami/action/rack/file.rb
hanami-controller-2.0.0 lib/hanami/action/rack/file.rb
hanami-controller-2.0.0.rc1 lib/hanami/action/rack/file.rb