Sha256: 219e76b772dda493146e0bb95e688aa8116aaa593c58a581b31bfd2c88e33fa4
Contents?: true
Size: 824 Bytes
Versions: 3
Compression:
Stored size: 824 Bytes
Contents
require 'hanami/utils/json' require_relative 'errors' module Hanami module Middleware class BodyParser # @since 1.3.0 # @api private class JsonParser # @since 1.3.0 # @api private def mime_types ['application/json', 'application/vnd.api+json'] end # Parse a json string # # @param body [String] a json string # # @return [Hash] the parsed json # # @raise [Hanami::Middleware::BodyParser::BodyParsingError] when the body can't be parsed. # # @since 1.3.0 # @api private def parse(body) Hanami::Utils::Json.parse(body) rescue Hanami::Utils::Json::ParserError => e raise BodyParsingError.new(e.message) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems