Sha256: 790cb9417c1385a4e5931d93b810403fc9bb81d8e55998d7463eec0c2c5732ba
Contents?: true
Size: 838 Bytes
Versions: 3
Compression:
Stored size: 838 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 self.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
3 entries across 3 versions & 1 rubygems