Class | Faraday::Connection |
In: |
lib/faraday/connection.rb
|
Parent: | Object |
HEADERS | = | Hash.new { |h, k| k.respond_to?(:to_str) ? k : k.to_s.capitalize }.update \ :content_type => "Content-Type", :content_length => "Content-Length", :accept_charset => "Accept-Charset", :accept_encoding => "Accept-Encoding" |
METHODS | = | Set.new [:get, :post, :put, :delete, :head] |
METHODS_WITH_BODIES | = | Set.new [:post, :put] |
builder | [R] | |
headers | [RW] | |
host | [RW] | |
options | [R] | |
parallel_manager | [RW] | |
params | [RW] | |
path_prefix | [R] | |
port | [RW] | |
scheme | [RW] | |
ssl | [R] |
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
turns headers keys and values into strings. Look up symbol keys in the the HEADERS hash.
h = merge_headers(HeaderHash.new, :content_type => 'text/plain') h['Content-Type'] # = 'text/plain'
Parses the giving url with Addressable::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