Sha256: 73a24af75140c6881f9bfd615f96d804c19c7704bcd5d9fd31ad7b1e62678542
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
# frozen_string_literal: true module Hanami module Middleware class BodyParser # Body parser abstract class # # @since 2.0.0 class Parser DEFAULT_MIME_TYPES = [].freeze # Return supported mime types # # @return [Array<String>] supported MIME types # # @abstract # @since 2.0.0 # # @example # require "hanami/middleware/body_parser" # # class XMLParser < Hanami::Middleware::BodyParser::Parser # def self.mime_types # ["application/xml", "text/xml"] # end # end attr_reader :mime_types # @api private def initialize(mime_types: DEFAULT_MIME_TYPES) @mime_types = self.class.mime_types + mime_types end # Parse raw HTTP request body # # @param body [String] HTTP request body # # @return [Hash] the result of the parsing # # @raise [Hanami::Middleware::BodyParser::BodyParsingError] the error # that must be raised if the parsing cannot be accomplished # # @abstract # @since 2.0.0 # # @example # require "hanami/middleware/body_parser" # # class XMLParser < Hanami::Middleware::BodyParser::Parser # def parse(body) # # XML parsing # # ... # rescue => exception # raise Hanami::Middleware::BodyParser::BodyParsingError.new(exception.message) # end # end def parse(body) # rubocop:disable Lint/UnusedMethodArgument raise NoMethodError end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hanami-router-2.0.0 | lib/hanami/middleware/body_parser/parser.rb |
hanami-router-2.0.0.rc1 | lib/hanami/middleware/body_parser/parser.rb |