Class: SearchFlip::HTTPClient

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/search_flip/http_client.rb

Overview

The SearchFlip::HTTPClient class wraps the http gem and responsible for the http request/response handling, ie communicating with Elasticsearch. You only need to use it directly if you need authentication to communicate with Elasticsearch or if you want to set some custom http settings.

Examples:

http_client = SearchFlip::HTTPClient.new

# Basic Auth
http_client = http_client.basic_auth(user: "username", pass: "password")

# Raw Auth Header
http_client = http_client.auth("Bearer VGhlIEhUVFAgR2VtLCBST0NLUw")

# Proxy Settings
http_client = http_client.via("proxy.host", 8080)

# Custom headers
http_client = http_client.headers(key: "value")

# Timeouts
http_client = http_client.timeout(20)

SearchFlip::Connection.new(base_url: "...", http_client: http_client)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugins: []) ⇒ HTTPClient

Returns a new instance of HTTPClient.



30
31
32
33
# File 'lib/search_flip/http_client.rb', line 30

def initialize(plugins: [])
  self.request = HTTP
  self.plugins = plugins
end

Instance Attribute Details

#pluginsObject

Returns the value of attribute plugins.



28
29
30
# File 'lib/search_flip/http_client.rb', line 28

def plugins
  @plugins
end

#requestObject

Returns the value of attribute request.



28
29
30
# File 'lib/search_flip/http_client.rb', line 28

def request
  @request
end