Class: HttpClientGenerator::Plugs::SetBearerToken
- Inherits:
-
Object
- Object
- HttpClientGenerator::Plugs::SetBearerToken
- Defined in:
- lib/http_client_generator/plugs/set_bearer_token.rb
Instance Method Summary collapse
- #call(req) ⇒ Object
-
#initialize(from_arg:) ⇒ SetBearerToken
constructor
A new instance of SetBearerToken.
Constructor Details
#initialize(from_arg:) ⇒ SetBearerToken
Returns a new instance of SetBearerToken.
8 9 10 |
# File 'lib/http_client_generator/plugs/set_bearer_token.rb', line 8 def initialize(from_arg:) @from_arg = from_arg end |
Instance Method Details
#call(req) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/http_client_generator/plugs/set_bearer_token.rb', line 12 def call(req) token = req.rest_args[@from_arg] req.headers[:authorization] = "Bearer #{token}" req end |