A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://rubydoc.info/github/piotrmurach/github/master/Github/Request/BasicAuth below:

BasicAuth – Documentation for piotrmurach/github (master) – RubyDoc.info

Class: Github::Request::BasicAuth
Inherits:
Faraday::Middleware show all
Defined in:
lib/github_api/request/basic_auth.rb
Instance Method Summary collapse 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_api/request/basic_auth.rb', line 12

def initialize(app, *args)
  @app    = app
  @auth   = nil
  options = args.

  if options.key?(:login) && !options[:login].nil?
    credentials = "#{options[:login]}:#{options[: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_api/request/basic_auth.rb', line 27

def call(env)
  if @auth
    env[:request_headers].merge!('Authorization' => "Basic #{@auth}")
  end

  @app.call(env)
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4