Class: Request::BasicAuthentication

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/gh/faraday.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, login, pass) ⇒ BasicAuthentication

Returns a new instance of BasicAuthentication.



31
32
33
34
# File 'lib/gh/faraday.rb', line 31

def initialize(app, , pass)
  super(app)
  @header_value = "Basic #{Base64.encode64([, pass].join(':')).gsub("\n", '')}"
end

Instance Method Details

#call(env) ⇒ Object



36
37
38
39
40
41
# File 'lib/gh/faraday.rb', line 36

def call(env)
  unless env[:request_headers]['Authorization']
    env[:request_headers]['Authorization'] = @header_value
  end
  @app.call(env)
end