Class: Request::BasicAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Request::BasicAuth
- Defined in:
- lib/faraday/request/basic_auth.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options) ⇒ BasicAuth
constructor
A new instance of BasicAuth.
Constructor Details
#initialize(app, options) ⇒ BasicAuth
Returns a new instance of BasicAuth.
13 14 15 |
# File 'lib/faraday/request/basic_auth.rb', line 13 def initialize(app, ) @app, @options = app, end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 |
# File 'lib/faraday/request/basic_auth.rb', line 7 def call(env) header = Base64.encode64("#{@options[:username]}:#{@options[:password]}") env[:request_headers]['Authorization'] = "Basic #{header.to_s}" @app.call(env) end |