Class: Github::Request::BasicAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Github::Request::BasicAuth
- Defined in:
- lib/github_api2/request/basic_auth.rb
Instance Method Summary collapse
-
#call(env) ⇒ Object
private
Update request headers.
-
#initialize(app, *args) ⇒ BasicAuth
constructor
private
A new instance of BasicAuth.
Constructor Details
#initialize(app, *args) ⇒ BasicAuth
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BasicAuth.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/github_api2/request/basic_auth.rb', line 12 def initialize(app, *args) @app = app @auth = nil = args. if .key?(:login) && ![:login].nil? credentials = "#{[:login]}:#{[:password]}" @auth = Base64.encode64(credentials) @auth.gsub!("\n", "") end end |
Instance Method Details
#call(env) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Update request headers
27 28 29 30 31 32 33 |
# File 'lib/github_api2/request/basic_auth.rb', line 27 def call(env) if @auth env[:request_headers].merge!('Authorization' => "Basic #{@auth}") end @app.call(env) end |