Sha256: b6db60fd6b9f865ea4713ebf96869baf526ff51306938e2a9ac2b9a29ab6942e

Contents?: true

Size: 912 Bytes

Versions: 17

Compression:

Stored size: 912 Bytes

Contents

require 'multi_json'

module Aws
  module Json

    # This plugin performs two trivial translations:
    #
    # * The request parameters are serialized as JSON for the request body
    # * The response body is deserialized as JSON for the response data
    #
    # No attempt is made to extract errors from the HTTP response body.
    # Parsing the response only happens for a successful response.
    #
    class SimpleBodyHandler < Seahorse::Client::Handler

      def call(context)
        build_json(context)
        @handler.call(context).on_success do |response|
          response.error = nil
          response.data = parse_json(context)
        end
      end

      private

      def build_json(context)
        context.http_request.body = MultiJson.dump(context.params)
      end

      def parse_json(context)
        MultiJson.load(context.http_response.body_contents)
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.10 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.9 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.8 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.7 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.6 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.5 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.4 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.3 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.2 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.1 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.0 lib/aws-sdk-core/json/simple_body_handler.rb
aws-sdk-core-2.0.0.rc16 lib/aws/json/simple_body_handler.rb
aws-sdk-core-2.0.0.rc15 lib/aws/json/simple_body_handler.rb
aws-sdk-core-2.0.0.rc14 lib/aws/json/simple_body_handler.rb
aws-sdk-core-2.0.0.rc13 lib/aws/json/simple_body_handler.rb
aws-sdk-core-2.0.0.rc12 lib/aws/json/simple_body_handler.rb
aws-sdk-core-2.0.0.rc11 lib/aws/json/simple_body_handler.rb