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 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

[Validate]