Back to Faraday

Proxy Options

docs/customization/proxy-options.md

2.14.1928 B
Original Source

Proxy Options

Proxy options can be provided to the connection constructor or set on a per-request basis via RequestOptions. All these options are optional.

OptionTypeDefaultDescription
:uriURI, StringnilProxy URL.
:userStringnilProxy user.
:passwordStringnilProxy password.

Example

ruby
# Proxy options can be passed to the connection constructor and will be applied to all requests.
proxy_options = {
  uri: 'http://proxy.example.com:8080',
  user: 'username',
  password: 'password'
}

conn = Faraday.new(proxy: proxy_options) do |faraday|
  # ...
end

# You can then override them on a per-request basis.
conn.get('/foo') do |req|
  req.options.proxy.update(uri: 'http://proxy2.example.com:8080')
end