Class: Schwab::Middleware::Authentication
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Schwab::Middleware::Authentication
- Defined in:
- lib/schwab/middleware/authentication.rb
Overview
Simple middleware for adding bearer token to requests
Instance Method Summary collapse
-
#call(env) ⇒ Faraday::Response
Add bearer token to the request.
-
#initialize(app, token) ⇒ Authentication
constructor
A new instance of Authentication.
Constructor Details
#initialize(app, token) ⇒ Authentication
Returns a new instance of Authentication.
86 87 88 89 |
# File 'lib/schwab/middleware/authentication.rb', line 86 def initialize(app, token) super(app) @token = token end |
Instance Method Details
#call(env) ⇒ Faraday::Response
Add bearer token to the request
94 95 96 97 |
# File 'lib/schwab/middleware/authentication.rb', line 94 def call(env) env[:request_headers]["Authorization"] = "Bearer #{@token}" if @token @app.call(env) end |