module Aws::Rails

def self.add_sqsd_middleware(app)

The expectation is this variable should only be set on EB worker environments.
This will only be added in the presence of the AWS_PROCESS_BEANSTALK_WORKER_REQUESTS environment variable.
Register a middleware that will handle requests from the Elastic Beanstalk worker SQS Daemon.
def self.add_sqsd_middleware(app)
  is_eb_worker_hosted = Aws::Util.str_2_bool(ENV['AWS_PROCESS_BEANSTALK_WORKER_REQUESTS'].to_s.downcase)
  return unless is_eb_worker_hosted
  if app.config.force_ssl
    # SQS Daemon sends requests over HTTP - allow and process them before enforcing SSL.
    app.config.middleware.insert_before(ActionDispatch::SSL, Aws::Rails::EbsSqsActiveJobMiddleware)
  else
    app.config.middleware.use(Aws::Rails::EbsSqsActiveJobMiddleware)
  end
end