update readme with proxy docs

This commit is contained in:
technoweenie 2012-12-30 11:41:53 -07:00
parent e63f490693
commit c17a3c6adb

View File

@ -24,6 +24,17 @@ conn = Faraday.new(:url => 'http://sushi.com') do |faraday|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
end
# set proxy with string
conn.options.proxy = "http://user:password@example.org/"
# set proxy with hash
conn.options.proxy = { :uri => 'http://user:passwordexample.org' }
# specify proxy user/pass
conn.options.proxy = { :uri => 'http://user:pass.org',
:user => 'user',
:password => 'pass' }
## GET ##
response = conn.get '/nigiri/sake.json' # GET http://sushi.com/nigiri/sake.json
@ -51,8 +62,19 @@ end
conn.get do |req|
req.url '/search'
req.options[:timeout] = 5 # open/read timeout in seconds
req.options[:open_timeout] = 2 # connection open timeout in seconds
req.options.timeout = 5 # open/read timeout in seconds
req.options.open_timeout = 2 # connection open timeout in seconds
# set proxy with string
req.options.proxy = "http://user:password@example.org/"
# set proxy with hash
req.options.proxy = { :uri => 'http://user:passwordexample.org' }
# specify proxy user/pass
req.options.proxy = { :uri => 'http://user:pass.org',
:user => 'user',
:password => 'pass' }
end
```