Class: Griddler::AmazonSES::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/griddler/amazon_ses/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



4
5
6
# File 'lib/griddler/amazon_ses/middleware.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/griddler/amazon_ses/middleware.rb', line 8

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 is_griddler_request?(env) && is_aws_sns_request?(env)
    env['CONTENT_TYPE'] = 'application/json; charset=UTF-8'
  end

  @app.call(env)
end