Sha256: ea51d2bbdf44fe69501067edb0382b439df9f118390e46096c3175cba714340c

Contents?: true

Size: 938 Bytes

Versions: 8

Compression:

Stored size: 938 Bytes

Contents

module Aws
  module Json
    class RpcBodyHandler < Seahorse::Client::Handler

      # @param [Seahorse::Client::RequestContext] context
      # @return [Seahorse::Client::Response]
      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)
        if shape = context.operation.input
          context.http_request.body = Builder.new.to_json(shape, context.params)
        else
          context.http_request.body = '{}'
        end
      end

      def parse_json(context)
        if output_shape = context.operation.output
          json = context.http_response.body_contents
          json = '{}' if json == ''
          Parser.new.parse(output_shape, json)
        else
          EmptyStructure.new
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
aws-sdk-core-2.0.14 lib/aws-sdk-core/json/rpc_body_handler.rb
aws-sdk-core-2.0.13 lib/aws-sdk-core/json/rpc_body_handler.rb
aws-sdk-core-2.0.12 lib/aws-sdk-core/json/rpc_body_handler.rb
aws-sdk-core-2.0.11 lib/aws-sdk-core/json/rpc_body_handler.rb
aws-sdk-core-2.0.10 lib/aws-sdk-core/json/rpc_body_handler.rb
aws-sdk-core-2.0.9 lib/aws-sdk-core/json/rpc_body_handler.rb
aws-sdk-core-2.0.8 lib/aws-sdk-core/json/rpc_body_handler.rb
aws-sdk-core-2.0.7 lib/aws-sdk-core/json/rpc_body_handler.rb