Class: PDC::Request::Token
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- PDC::Request::Token
- Includes:
- Logging
- Defined in:
- lib/pdc/http/request/pdc_token.rb
Overview
Adds TokenAuthentication to request header. Uses the token if passed else fetches token using the TokenFetcher to get the token once
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Token
constructor
A new instance of Token.
Methods included from Logging
Constructor Details
#initialize(app, options = {}) ⇒ Token
Returns a new instance of Token.
9 10 11 12 |
# File 'lib/pdc/http/request/pdc_token.rb', line 9 def initialize(app, = {}) @options = super(app) end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 |
# File 'lib/pdc/http/request/pdc_token.rb', line 14 def call(env) env.request_headers['Token'] = token logger.debug "Token set, headers: #{env.request_headers}" @app.call(env) end |