Class: Zaikio::Client::Helpers::AuthorizationMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Zaikio::Client::Helpers::AuthorizationMiddleware
- Defined in:
- lib/zaikio/client/helpers/authorization_middleware.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reset_token ⇒ Object
15 16 17 |
# File 'lib/zaikio/client/helpers/authorization_middleware.rb', line 15 def self.reset_token Thread.current[:zaikio_client_access_token] = nil end |
.token ⇒ Object
7 8 9 |
# File 'lib/zaikio/client/helpers/authorization_middleware.rb', line 7 def self.token Thread.current[:zaikio_client_access_token] end |
.token=(value) ⇒ Object
11 12 13 |
# File 'lib/zaikio/client/helpers/authorization_middleware.rb', line 11 def self.token=(value) Thread.current[:zaikio_client_access_token] = value end |
Instance Method Details
#call(request_env) ⇒ Object
19 20 21 22 23 |
# File 'lib/zaikio/client/helpers/authorization_middleware.rb', line 19 def call(request_env) request_env[:request_headers]["Authorization"] = "Bearer #{self.class.token}" if self.class.token @app.call(request_env) end |