Class: BitflyerApi::HTTP::Middleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- BitflyerApi::HTTP::Middleware
- Defined in:
- lib/bitflyer_api/http/middleware.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, key, secret) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, key, secret) ⇒ Middleware
Returns a new instance of Middleware.
9 10 11 12 13 |
# File 'lib/bitflyer_api/http/middleware.rb', line 9 def initialize(app, key, secret) super(app) @key = key @secret = secret end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'lib/bitflyer_api/http/middleware.rb', line 7 def key @key end |
#secret ⇒ Object
Returns the value of attribute secret.
7 8 9 |
# File 'lib/bitflyer_api/http/middleware.rb', line 7 def secret @secret end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/bitflyer_api/http/middleware.rb', line 15 def call(env) return @app.call(env) if key.nil? || secret.nil? env[:request_headers]["ACCESS-KEY"] = key if key env[:request_headers]["ACCESS-TIMESTAMP"] = env[:request_headers]["ACCESS-SIGN"] = signature(env, secret) @app.call env end |