Class: AwsV4Signer

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/aws_v4_signer_impl.rb

Defined Under Namespace

Classes: Request

Instance Method Summary collapse

Constructor Details

#initialize(app, options = nil) ⇒ AwsV4Signer

Returns a new instance of AwsV4Signer.



32
33
34
35
36
37
38
39
# File 'lib/aws_v4_signer_impl.rb', line 32

def initialize(app, options = nil)
  super(app)
  credentials = options.fetch(:credentials)
  service_name = options.fetch(:service_name)
  region = options.fetch(:region) || "us-east-1"
  @signer = Aws::Signers::V4.new(credentials, service_name, region)
  @net_http = app.is_a?(Faraday::Adapter::NetHttp)
end

Instance Method Details

#call(env) ⇒ Object



41
42
43
44
45
46
# File 'lib/aws_v4_signer_impl.rb', line 41

def call(env)
  normalize_for_net_http!(env)
  req = Request.new(env)
  @signer.sign(req)
  @app.call(env)
end