Sha256: c3280997de512d43ae41427182e3c93dc9c3671ce1ccaeb7127be6380e67d4ca
Contents?: true
Size: 833 Bytes
Versions: 5
Compression:
Stored size: 833 Bytes
Contents
# frozen_string_literal: true require "json" require_relative "parser" module Hanami module Middleware class BodyParser # @since 1.3.0 # @api private class JsonParser < Parser # @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) JSON.parse(body) rescue StandardError => exception raise BodyParsingError.new(exception.message) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems