Class: Github::Request::BasicAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Github::Request::BasicAuth
- Defined in:
- lib/github_api/request/basic_auth.rb
Instance Method Summary (collapse)
- - (Object) call(env)
-
- (BasicAuth) initialize(app, *args)
constructor
A new instance of BasicAuth.
Constructor Details
- (BasicAuth) initialize(app, *args)
A new instance of BasicAuth
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/github_api/request/basic_auth.rb', line 17 def initialize(app, *args) @app = app credentials = "" = args. if .has_key? :login credentials = "#{[:login]}:#{[:password]}" elsif .has_key? :basic_auth credentials = "#{[:basic_auth]}" end @auth = Base64.encode64(credentials) @auth.gsub!("\n", "") end |
Instance Method Details
- (Object) call(env)
11 12 13 14 15 |
# File 'lib/github_api/request/basic_auth.rb', line 11 def call(env) env[:request_headers].merge!('Authorization' => "Basic #{@auth}\"") @app.call env end |