Module: BunnyStream

Extended by:
Dry::Configurable
Defined in:
lib/bunny_stream.rb,
lib/bunny_stream/storage.rb,
lib/bunny_stream/version.rb

Defined Under Namespace

Classes: Storage

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.http(access_key = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bunny_stream.rb', line 14

def self.http(access_key = nil)
    default_options = {
        headers: {
          accept: 'application/json',
          content_type: 'application/json',
          user_agent: "BunnyStream Ruby Client #{BunnyStream::VERSION}",
        },
        timeout_class: HTTP::Timeout::Global,
        timeout_options: { global_timeout: 120 }
      }

      default_options = HTTP::Options.new(default_options)

  # .use(:auto_inflate) doesn't seem to work here
  @http ||= HTTP::Client.new(default_options).headers(
    {
        'AccessKey' => (access_key || BunnyStream.config.access_key)
    }
  )
end