Class: Ey::Hmac::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/ey-hmac/rack.rb

Overview

Request middleware that performs HMAC request signing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, key_id, key_secret, options = {}) ⇒ Rack

Returns a new instance of Rack.



7
8
9
10
11
12
# File 'lib/ey-hmac/rack.rb', line 7

def initialize(app, key_id, key_secret, options = {})
  @app = app
  @key_id = key_id
  @key_secret = key_secret
  @options = options
end

Instance Attribute Details

#key_idObject (readonly)

Returns the value of attribute key_id.



5
6
7
# File 'lib/ey-hmac/rack.rb', line 5

def key_id
  @key_id
end

#key_secretObject (readonly)

Returns the value of attribute key_secret.



5
6
7
# File 'lib/ey-hmac/rack.rb', line 5

def key_secret
  @key_secret
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/ey-hmac/rack.rb', line 5

def options
  @options
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
# File 'lib/ey-hmac/rack.rb', line 14

def call(env)
  Ey::Hmac.sign!(env, key_id, key_secret, { adapter: Ey::Hmac::Adapter::Rack }.merge(options))

  @app.call(env)
end