Sha256: 8467e6557945342ac8849aea4834ea17e24bda9ca1c14d64faa322f765f5c0dc

Contents?: true

Size: 777 Bytes

Versions: 1

Compression:

Stored size: 777 Bytes

Contents

module Griddler
  module Ses
    class Middleware
      def initialize(app)
        @app = app
      end

      def call(env)
        # a bug on the AWS side doesn't set the content type to application/json type properly,
        # so we have to intercept and do this in order for Griddler's controller to correctly
        # parse the parameters (see https://forums.aws.amazon.com/thread.jspa?messageID=418160)
        if env['REQUEST_PATH'] == griddler_path
          env['CONTENT_TYPE'] = 'application/json; charset=UTF-8'
        end

        @app.call(env)
      end

      private
      def griddler_path
        @griddler_path ||= Rails.application.routes.url_helpers.url_for(controller: 'griddler/emails', action: 'create', only_path: true)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
griddler-ses-1.0.2 lib/griddler/ses/middleware.rb