Class: Flipper::Adapters::Http::Client
- Inherits:
-
Object
- Object
- Flipper::Adapters::Http::Client
- Defined in:
- lib/flipper/adapters/http/client.rb
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'User-Agent' => "Flipper HTTP Adapter v#{VERSION}", }.freeze
- HTTPS_SCHEME =
"https".freeze
Instance Attribute Summary collapse
-
#basic_auth_password ⇒ Object
readonly
Returns the value of attribute basic_auth_password.
-
#basic_auth_username ⇒ Object
readonly
Returns the value of attribute basic_auth_username.
-
#debug_output ⇒ Object
readonly
Returns the value of attribute debug_output.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#max_retries ⇒ Object
readonly
Returns the value of attribute max_retries.
-
#open_timeout ⇒ Object
readonly
Returns the value of attribute open_timeout.
-
#read_timeout ⇒ Object
readonly
Returns the value of attribute read_timeout.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#write_timeout ⇒ Object
readonly
Returns the value of attribute write_timeout.
Instance Method Summary collapse
- #delete(path, body = nil) ⇒ Object
- #get(path) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, body = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/flipper/adapters/http/client.rb', line 21 def initialize( = {}) @uri = URI(.fetch(:url)) @headers = DEFAULT_HEADERS.merge([:headers] || {}) @basic_auth_username = [:basic_auth_username] @basic_auth_password = [:basic_auth_password] @read_timeout = [:read_timeout] @open_timeout = [:open_timeout] @write_timeout = [:write_timeout] @max_retries = .key?(:max_retries) ? [:max_retries] : 0 @debug_output = [:debug_output] end |
Instance Attribute Details
#basic_auth_password ⇒ Object (readonly)
Returns the value of attribute basic_auth_password.
18 19 20 |
# File 'lib/flipper/adapters/http/client.rb', line 18 def basic_auth_password @basic_auth_password end |
#basic_auth_username ⇒ Object (readonly)
Returns the value of attribute basic_auth_username.
18 19 20 |
# File 'lib/flipper/adapters/http/client.rb', line 18 def basic_auth_username @basic_auth_username end |
#debug_output ⇒ Object (readonly)
Returns the value of attribute debug_output.
19 20 21 |
# File 'lib/flipper/adapters/http/client.rb', line 19 def debug_output @debug_output end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
17 18 19 |
# File 'lib/flipper/adapters/http/client.rb', line 17 def headers @headers end |
#max_retries ⇒ Object (readonly)
Returns the value of attribute max_retries.
19 20 21 |
# File 'lib/flipper/adapters/http/client.rb', line 19 def max_retries @max_retries end |
#open_timeout ⇒ Object (readonly)
Returns the value of attribute open_timeout.
19 20 21 |
# File 'lib/flipper/adapters/http/client.rb', line 19 def open_timeout @open_timeout end |
#read_timeout ⇒ Object (readonly)
Returns the value of attribute read_timeout.
19 20 21 |
# File 'lib/flipper/adapters/http/client.rb', line 19 def read_timeout @read_timeout end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
17 18 19 |
# File 'lib/flipper/adapters/http/client.rb', line 17 def uri @uri end |
#write_timeout ⇒ Object (readonly)
Returns the value of attribute write_timeout.
19 20 21 |
# File 'lib/flipper/adapters/http/client.rb', line 19 def write_timeout @write_timeout end |
Instance Method Details
#delete(path, body = nil) ⇒ Object
41 42 43 |
# File 'lib/flipper/adapters/http/client.rb', line 41 def delete(path, body = nil) perform Net::HTTP::Delete, path, @headers, body: body end |
#get(path) ⇒ Object
33 34 35 |
# File 'lib/flipper/adapters/http/client.rb', line 33 def get(path) perform Net::HTTP::Get, path, @headers end |
#post(path, body = nil) ⇒ Object
37 38 39 |
# File 'lib/flipper/adapters/http/client.rb', line 37 def post(path, body = nil) perform Net::HTTP::Post, path, @headers, body: body end |