Module: Webpagetest::Connection

Included in:
Client, Response
Defined in:
lib/webpagetest/connection.rb

Overview

Configures and performs connection requests

Constant Summary collapse

ENDPOINT =
'http://www.webpagetest.org/'

Instance Method Summary collapse

Instance Method Details

#get_connection(options = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/webpagetest/connection.rb', line 7

def get_connection(options = nil)
  options = Hashie::Mash.new( {
    request: :url_encoded,
    response: :logger,
    adapter: Faraday.default_adapter,        
  } ) if options.nil?
  
  url = options.url || ENDPOINT

  connection = Faraday.new(url: url) do |faraday|
    faraday.request  options.request
    faraday.response options.response
    faraday.adapter  options.adapter
  end
end