class Aws::Json::Handler
Constants
- CONTENT_TYPE
Public Instance Methods
call(context)
click to toggle source
@param [Seahorse::Client::RequestContext] context @return [Seahorse::Client::Response]
# File lib/aws-sdk-core/json/handler.rb, line 9 def call(context) build_request(context) response = @handler.call(context) response.on(200..299) { |resp| parse_response(resp) } response.on(200..599) { |resp| apply_request_id(context) } response end
Private Instance Methods
apply_request_id(context)
click to toggle source
# File lib/aws-sdk-core/json/handler.rb, line 57 def apply_request_id(context) context[:request_id] = context.http_response.headers['x-amzn-requestid'] end
build_body(context)
click to toggle source
# File lib/aws-sdk-core/json/handler.rb, line 26 def build_body(context) if simple_json?(context) Json.dump(context.params) else Builder.new(context.operation.input).serialize(context.params) end end
build_request(context)
click to toggle source
# File lib/aws-sdk-core/json/handler.rb, line 19 def build_request(context) context.http_request.http_method = 'POST' context.http_request.headers['Content-Type'] = content_type(context) context.http_request.headers['X-Amz-Target'] = target(context) context.http_request.body = build_body(context) end
content_type(context)
click to toggle source
# File lib/aws-sdk-core/json/handler.rb, line 48 def content_type(context) CONTENT_TYPE % [context.config.api.metadata['jsonVersion']] end
parse_body(context)
click to toggle source
# File lib/aws-sdk-core/json/handler.rb, line 38 def parse_body(context) if simple_json?(context) Json.load(context.http_response.body_contents) else rules = context.operation.output json = context.http_response.body_contents Parser.new(rules).parse(json == '' ? '{}' : json) end end
parse_response(response)
click to toggle source
# File lib/aws-sdk-core/json/handler.rb, line 34 def parse_response(response) response.data = parse_body(response.context) end
simple_json?(context)
click to toggle source
# File lib/aws-sdk-core/json/handler.rb, line 61 def simple_json?(context) context.config.simple_json end
target(context)
click to toggle source
# File lib/aws-sdk-core/json/handler.rb, line 52 def target(context) prefix = context.config.api.metadata['targetPrefix'] "#{prefix}.#{context.operation.name}" end