Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 1.19 KB

faraday-configuration.md

File metadata and controls

28 lines (19 loc) · 1.19 KB

Flexirest: Faraday configuration

Flexirest uses Faraday to allow switching HTTP backends, the default is to just use Faraday's default. To change the used backend just set it in the class by setting adapter to a Faraday supported adapter symbol.

Flexirest::Base.adapter = :net_http
# or ...
Flexirest::Base.adapter = :patron

In versions before 1.2.0 the adapter was hardcoded to :patron, so if you want to ensure it still uses Patron, you should set this setting.

If you want more control you can pass a complete configuration block ("complete" means that the block does not override the default configuration, but rather replaces it).

For available configuration variables look into the Faraday documentation.

Flexirest::Base.faraday_config do |faraday|
  faraday.adapter(:net_http)
  faraday.options.timeout       = 10
  faraday.headers['User-Agent'] = "Flexirest/#{Flexirest::VERSION}"
end

< Ruby on Rails integration | Associations >