Class: HttpResource::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/http_resource/configuration.rb

Overview

Holds the settings for building a default client (HttpResource.client). Framework-generic: no app-specific env names. A host sets these explicitly in an initializer, mapping ITS own env vars onto them.

HttpResource.configure do |c|
  c.base_url = ENV.fetch("API_URL")
  c.auth = HttpResource::Auth.bearer(ENV.fetch("API_TOKEN"))
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



15
16
17
18
19
20
# File 'lib/http_resource/configuration.rb', line 15

def initialize
  @base_url = nil
  @auth = nil
  @open_timeout = Client::DEFAULT_OPEN_TIMEOUT
  @read_timeout = Client::DEFAULT_READ_TIMEOUT
end

Instance Attribute Details

#authObject

Returns the value of attribute auth.



13
14
15
# File 'lib/http_resource/configuration.rb', line 13

def auth
  @auth
end

#base_urlObject

Returns the value of attribute base_url.



13
14
15
# File 'lib/http_resource/configuration.rb', line 13

def base_url
  @base_url
end

#open_timeoutObject

Returns the value of attribute open_timeout.



13
14
15
# File 'lib/http_resource/configuration.rb', line 13

def open_timeout
  @open_timeout
end

#read_timeoutObject

Returns the value of attribute read_timeout.



13
14
15
# File 'lib/http_resource/configuration.rb', line 13

def read_timeout
  @read_timeout
end