Class: Zaikio::Directory::AuthorizationMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Zaikio::Directory::AuthorizationMiddleware
- Defined in:
- lib/zaikio/directory/authorization_middleware.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reset_token ⇒ Object
18 19 20 |
# File 'lib/zaikio/directory/authorization_middleware.rb', line 18 def self.reset_token self.token = nil end |
.token ⇒ Object
8 9 10 11 |
# File 'lib/zaikio/directory/authorization_middleware.rb', line 8 def self.token @token ||= Concurrent::ThreadLocalVar.new { nil } @token.value end |
.token=(value) ⇒ Object
13 14 15 16 |
# File 'lib/zaikio/directory/authorization_middleware.rb', line 13 def self.token=(value) @token ||= Concurrent::ThreadLocalVar.new { nil } @token.value = value end |
Instance Method Details
#call(request_env) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/zaikio/directory/authorization_middleware.rb', line 22 def call(request_env) if self.class.token request_env[:request_headers]["Authorization"] = "Bearer #{self.class.token}" end @app.call(request_env).on_complete do |response_env| end end |