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.



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

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

Instance Attribute Details

#key_idObject (readonly)

Returns the value of attribute key_id.



3
4
5
# File 'lib/ey-hmac/rack.rb', line 3

def key_id
  @key_id
end

#key_secretObject (readonly)

Returns the value of attribute key_secret.



3
4
5
# File 'lib/ey-hmac/rack.rb', line 3

def key_secret
  @key_secret
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/ey-hmac/rack.rb', line 3

def options
  @options
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
# File 'lib/ey-hmac/rack.rb', line 11

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

  @app.call(env)
end