Method: TentClient#new_http

Defined in:
lib/tent-client.rb

#new_httpObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/tent-client.rb', line 75

def new_http
  authentication_options = {}
  authentication_options[:ts_skew] = @ts_skew if @ts_skew
  authentication_options[:ts_skew_retry_enabled] = @options.has_key?(:ts_skew_retry_enabled) ? @options[:ts_skew_retry_enabled] : true
  authentication_options[:update_ts_skew] = proc do |skew|
    @ts_skew = skew
  end

  @http = CycleHTTP.new(self) do |f|
    f.use Middleware::ContentTypeHeader
    f.use Middleware::EncodeJson unless @options[:skip_serialization]
    f.use Middleware::Authentication, @options[:credentials], authentication_options if @options[:credentials]
    f.response :multi_json, :content_type => /\bjson\Z/ unless @options[:skip_serialization] || @options[:skip_response_serialization]
    @faraday_setup.call(f) if @faraday_setup
    f.adapter *Array(faraday_adapter)
  end
end