module Restfolia::HTTP::Configuration
Internal: Simply a bag of HTTP
options like headers, cookies, auth … etc.
Attributes
Public Instance Methods
as(content_type)
click to toggle source
Public: A fluent way to add Content-Type and Accept headers.
content_type - String value. Ex: “application/json”
Returns self, always!
# File lib/restfolia/http/configuration.rb, line 58 def as(content_type) headers["Content-Type"] = content_type headers["Accept"] = content_type self end
headers()
click to toggle source
Public: Returns Hash to be used as Headers on request.
# File lib/restfolia/http/configuration.rb, line 10 def headers @headers ||= {} end
with_headers(new_headers)
click to toggle source
Public: A fluent way to add HTTP
headers. Headers informed here are merged with headers attribute.
new_headers - Hash with headers.
Examples
entry_point = Restfolia.at("http://fake.com") entry_point.with_headers("X-Custom1" => "value", "X-Custom2" => "value2").get
Returns self, always! Raises ArgumentError unless new_headers is a Hash.
# File lib/restfolia/http/configuration.rb, line 44 def with_headers(new_headers) unless new_headers.is_a?(Hash) raise ArgumentError, "New Headers should Hash object." end headers.merge!(new_headers) self end
Protected Instance Methods
configuration()
click to toggle source
Returns Hash with headers, cookies, auth … etc.
# File lib/restfolia/http/configuration.rb, line 67 def configuration {:headers => headers, :cookies => cookies} end