Sha256: 8c7743dbc21035587691cbfbef6ec005dd5acbe7fb9585015637fae8253dcf33

Contents?: true

Size: 999 Bytes

Versions: 5

Compression:

Stored size: 999 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)
        #
        # @param body [String] a multipart body
        #
        # @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

5 entries across 5 versions & 1 rubygems

Version Path
hanami-router-2.1.0.rc2 lib/hanami/middleware/body_parser/form_parser.rb
hanami-router-2.1.0.rc1 lib/hanami/middleware/body_parser/form_parser.rb
hanami-router-2.1.0.beta1 lib/hanami/middleware/body_parser/form_parser.rb
hanami-router-2.0.2 lib/hanami/middleware/body_parser/form_parser.rb
hanami-router-2.0.1 lib/hanami/middleware/body_parser/form_parser.rb