Class: Evrythng::Request::TokenAuthentication
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Evrythng::Request::TokenAuthentication
- Defined in:
- lib/evrythng/request/token_authentication.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, token, options = {}) ⇒ TokenAuthentication
constructor
A new instance of TokenAuthentication.
Constructor Details
#initialize(app, token, options = {}) ⇒ TokenAuthentication
Returns a new instance of TokenAuthentication.
7 8 9 10 11 |
# File 'lib/evrythng/request/token_authentication.rb', line 7 def initialize(app, token, ={}) super(app) @header_value = token end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/evrythng/request/token_authentication.rb', line 13 def call(env) unless env[:request_headers]['X-Evrythng-Token'] env[:request_headers]['X-Evrythng-Token'] = @header_value end @app.call(env) end |