Sha256: 553f2dda6801db5e14254f4d364d4042a3d57cc87c276c5f5d611ad4dfa463dd

Contents?: true

Size: 1.16 KB

Versions: 183

Compression:

Stored size: 1.16 KB

Contents

require 'json'

# Hack AwsLambda Ruby Runtime to fix .to_json issue collision with ActiveSupport.
# To reproduce:
#   Create a shared resource from the docs and call sns.publish
#
# Causes an infinite loop when calling sns.publish somehow.
# Overriding with JSON.dump and follow up with AWS ticket.
module AwsLambda
  class Marshaller
    class << self
      # By default, just runs #to_json on the method's response value.
      # This can be overwritten by users who know what they are doing.
      # The response is an array of response, content-type.
      # If returned without a content-type, it is assumed to be application/json
      # Finally, StringIO/IO is used to signal a response that shouldn't be
      # formatted as JSON, and should get a different content-type header.
      def marshall_response(method_response)
        case method_response
        when StringIO, IO
          [method_response, 'application/unknown']
        else
          # Orignal method calls .to_json but this collides with ActiveSupport's to_json
          # method_response.to_json # application/json is assumed
          JSON.dump(method_response)
        end
      end

    end
  end
end

Version data entries

183 entries across 183 versions & 4 rubygems

Version Path
jets-4.0.12 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.11 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.10 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.9 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.8 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.7 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.6 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.5 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.4 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.3 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.2 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.1 lib/jets/overrides/lambda/marshaller.rb
jets-4.0.0 lib/jets/overrides/lambda/marshaller.rb
jets-3.2.2 lib/jets/overrides/lambda/marshaller.rb
jets-3.2.1 lib/jets/overrides/lambda/marshaller.rb
jets.benforeva-3.0.17.pre.mount.pre.fix lib/jets/overrides/lambda/marshaller.rb
jets-3.2.0 lib/jets/overrides/lambda/marshaller.rb
jets-3.1.5 lib/jets/overrides/lambda/marshaller.rb
jets-3.1.4 lib/jets/overrides/lambda/marshaller.rb
jets-3.1.3 lib/jets/overrides/lambda/marshaller.rb