Sha256: 8340d38205bc3ec4e6cac597d1e71b991c9bf461ab02232bc8f078a0f059a1d9

Contents?: true

Size: 941 Bytes

Versions: 6

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

require_relative "parser"
require "rack/multipart"

module Hanami
  module Middleware
    class BodyParser
      # @since 2.0.1
      # @api private
      class FormParser < Parser
        # @since 2.0.1
        # @api private
        MIME_TYPES = [
          "multipart/form-data"
        ].freeze

        # @since 2.0.1
        # @api private
        def self.mime_types
          MIME_TYPES
        end

        # Parse a multipart body payload (form file uploading)
        #
        # @return [Hash] the parsed multipart body
        #
        # @raise [Hanami::Middleware::BodyParser::BodyParsingError] when the body can't be parsed.
        #
        # @since 2.0.1
        # @api private
        def parse(*, env)
          ::Rack::Multipart.parse_multipart(env)
        rescue StandardError => exception
          raise BodyParsingError.new(exception.message)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hanami-router-2.2.0 lib/hanami/middleware/body_parser/form_parser.rb
hanami-router-2.2.0.rc1 lib/hanami/middleware/body_parser/form_parser.rb
hanami-router-2.2.0.beta2 lib/hanami/middleware/body_parser/form_parser.rb
hanami-router-2.2.0.beta1 lib/hanami/middleware/body_parser/form_parser.rb
hanami-router-2.1.0 lib/hanami/middleware/body_parser/form_parser.rb
hanami-router-2.1.0.rc3 lib/hanami/middleware/body_parser/form_parser.rb