Class: BitBucket::Request::BasicAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- BitBucket::Request::BasicAuth
- Defined in:
- lib/bitbucket_rest_api/request/basic_auth.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, *args) ⇒ BasicAuth
constructor
A new instance of BasicAuth.
Constructor Details
#initialize(app, *args) ⇒ BasicAuth
Returns a new instance of BasicAuth.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bitbucket_rest_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
#call(env) ⇒ Object
11 12 13 14 15 |
# File 'lib/bitbucket_rest_api/request/basic_auth.rb', line 11 def call(env) env[:request_headers].merge!('Authorization' => "Basic #{@auth}\"") @app.call env end |