class AwsV4Signer

Public Class Methods

new(app, options = nil) click to toggle source
Calls superclass method
# File lib/logstash/outputs/amazon_es/aws_v4_signer_impl.rb, line 39
def initialize(app, options = nil)
   super(app)
   @options = options
   @net_http = app.is_a?(Faraday::Adapter::NetHttp)
 end

Public Instance Methods

call(env) click to toggle source
# File lib/logstash/outputs/amazon_es/aws_v4_signer_impl.rb, line 45
def call(env)
  normalize_for_net_http!(env)
  req = Request.new(env)
  signer().sign(req)
  @app.call(env)
end
signer() click to toggle source
# File lib/logstash/outputs/amazon_es/aws_v4_signer_impl.rb, line 32
def signer
  credentials = @options.fetch(:credentials)
  service_name = @options.fetch(:service_name)
  region = @options.fetch(:region)
  Aws::Signers::V4.new(credentials, service_name, region)
end

Private Instance Methods

normalize_for_net_http!(env) click to toggle source
# File lib/logstash/outputs/amazon_es/aws_v4_signer_impl.rb, line 53
def normalize_for_net_http!(env)
  return unless @net_http

  if Net::HTTP::HAVE_ZLIB
    env.request_headers['Accept-Encoding'] ||= 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'
  end

  env.request_headers['Accept'] ||= '*/*'
end