Class Faraday::Connection
In: lib/faraday/connection.rb
Parent: Object

Methods

Constants

METHODS = Set.new [:get, :post, :put, :delete, :head, :patch, :options]
METHODS_WITH_BODIES = Set.new [:post, :put, :patch, :options]

Attributes

builder  [R] 
default_parallel_manager  [W] 
headers  [R] 
options  [R] 
parallel_manager  [R] 
params  [R] 
ssl  [R] 
url_prefix  [R] 

Public Class methods

normalize URI() behavior across Ruby versions

Public: Initializes a new Faraday::Connection.

url - URI or String base URL to use as a prefix for all

          requests (optional).

options - Hash of settings that will be applied to every request made

          from this Connection (default: {}).
          :url     - URI or String base URL (default: "http:/").
          :params  - Hash of URI query unencoded key/value pairs.
          :headers - Hash of unencoded HTTP header key/value pairs.
          :request - Hash of request options.
          :ssl     - Hash of SSL options.
          :proxy   - URI, String or Hash of HTTP proxy options
                    (default: "http_proxy" environment variable).
                    :uri      - URI or String
                    :user     - String (optional)
                    :password - String (optional)

Public Instance methods

The "rack app" wrapped in middleware. All requests are sent here.

The builder is responsible for creating the app object. After this, the builder gets locked to ensure no further modifications are made to the middleware stack.

Returns an object that responds to `call` and returns a Response.

Internal: Build an absolute URL based on url_prefix.

url - A String or URI-like object params - A Faraday::Utils::ParamsHash to replace the query values

         of the resulting url (default: nil).

Returns the resulting URI instance.

Internal: Creates and configures the request object.

Returns the new Request.

Takes a relative url for a request and combines it with the defaults set on the connection instance.

  conn = Faraday::Connection.new { ... }
  conn.url_prefix = "https://sushi.com/api?token=abc"
  conn.scheme      # => https
  conn.path_prefix # => "/api"

  conn.build_url("nigiri?page=2")      # => https://sushi.com/api/nigiri?token=abc&page=2
  conn.build_url("nigiri", :page => 2) # => https://sushi.com/api/nigiri?token=abc&page=2

Internal: Traverse the middleware stack in search of a parallel-capable adapter.

Yields in case of not found.

Returns a parallel manager or nil if not found.

Public: Replace default request headers.

Public: Replace default query parameters.

Ensures that the path prefix always has a leading but no trailing slash

Parses the giving url with URI and stores the individual components in this connection. These components serve as defaults for requests made by this connection.

  conn = Faraday::Connection.new { ... }
  conn.url_prefix = "https://sushi.com/api"
  conn.scheme      # => https
  conn.path_prefix # => "/api"

  conn.get("nigiri?page=2") # accesses https://sushi.com/api/nigiri

Internal: Yields username and password extracted from a URI if they both exist.

[Validate]