Class: CosmosAuthentication::Middleware::UseToken
- Inherits:
-
Object
- Object
- CosmosAuthentication::Middleware::UseToken
- Defined in:
- lib/cosmos_authentication/middleware/use_token.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, key = :current_body) ⇒ UseToken
constructor
A new instance of UseToken.
Constructor Details
#initialize(app, key = :current_body) ⇒ UseToken
Returns a new instance of UseToken.
4 5 6 7 |
# File 'lib/cosmos_authentication/middleware/use_token.rb', line 4 def initialize(app, key = :current_body) @app = app @key = key end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/cosmos_authentication/middleware/use_token.rb', line 9 def call(env) access_token = env[@key]['access_token'] header = {'Authentication' => "Bearer #{access_token}"} env[:client].tap { |client| client.headers.merge!(header) } @app.call env end |