Sha256: 4f979eba9f51eb361a1107846f69729f7143fa484fafdc504a6ae4dabc3deff2

Contents?: true

Size: 646 Bytes

Versions: 6

Compression:

Stored size: 646 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
        # @param path [String,Pathname] file path
        #
        # @since 0.4.3
        # @api private
        def initialize(path)
          @file = ::Rack::File.new(nil)
          @path = path
        end

        # @since 0.4.3
        # @api private
        def call(env)
          @file.path = @path.to_s
          @file.serving(env)
        rescue Errno::ENOENT
          [404, {}, nil]
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hanami-controller-0.8.1 lib/hanami/action/rack/file.rb
hanami-controller-0.8.0 lib/hanami/action/rack/file.rb
hanami-controller-0.7.1 lib/hanami/action/rack/file.rb
hanami-controller-0.7.0 lib/hanami/action/rack/file.rb
hanami-controller-0.6.1 lib/hanami/action/rack/file.rb
hanami-controller-0.6.0 lib/hanami/action/rack/file.rb