Class: Vodka::Client::Middleware::SignedRequest
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Vodka::Client::Middleware::SignedRequest
- Defined in:
- lib/vodka/client/middleware/signed_request.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #call(_env) ⇒ Object
-
#initialize(app, options = {}) ⇒ SignedRequest
constructor
A new instance of SignedRequest.
- #request_id ⇒ Object
- #request_signature ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ SignedRequest
Returns a new instance of SignedRequest.
7 8 9 |
# File 'lib/vodka/client/middleware/signed_request.rb', line 7 def initialize(app, = {}) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
5 6 7 |
# File 'lib/vodka/client/middleware/signed_request.rb', line 5 def app @app end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/vodka/client/middleware/signed_request.rb', line 5 def env @env end |
Instance Method Details
#call(_env) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/vodka/client/middleware/signed_request.rb', line 11 def call(_env) @env = _env env[:request_headers]['X-Request-Id'] = request_id env[:request_headers]['X-Request-Signature'] = request_signature env[:request_headers]['X-Response-Locale'] = I18n.locale.to_s if defined?(I18n) @app.call(env) end |
#request_id ⇒ Object
21 22 23 |
# File 'lib/vodka/client/middleware/signed_request.rb', line 21 def request_id @request_id ||= [Time.now.to_i, (rand * 100_000_000).to_i].join(?_) end |