Created
May 11, 2012 18:25
-
-
Save sfaxon/2661525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
require 'debugger' | |
@connection = Faraday.new("http://localhost") do |builder| | |
# builder.use Faraday::Request::BasicAuthentication.header('user', 'pass') | |
builder.adapter :test do |stub| | |
stub.get('/something') {[ 200, {}, 'yay' ]} | |
end | |
end | |
debugger | |
@connection.basic_auth('user', 'pass') # | |
puts @connection.builder.handlers.to_s # [Faraday::Adapter::Test] | |
puts @connection.url_prefix.to_s # http://localhost/ | |
puts @connection.get('/something').body # yay | |
puts @connection.get('/something').env[:request_headers] # {"Authorization"=>"Basic dXNlcjpwYXNz"} | |
########## | |
Farady connection: | |
def basic_auth(login, pass) | |
headers[Faraday::Request::Authorization::KEY] = | |
Faraday::Request::BasicAuthentication.header(login, pass) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment