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 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.
17 18 19 20 21 22 23 24 25 |
# File 'lib/flipper/adapters/http/client.rb', line 17 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] @debug_output = [:debug_output] end |
Instance Method Details
#delete(path, body = nil) ⇒ Object
35 36 37 |
# File 'lib/flipper/adapters/http/client.rb', line 35 def delete(path, body = nil) perform Net::HTTP::Delete, path, @headers, body: body end |
#get(path) ⇒ Object
27 28 29 |
# File 'lib/flipper/adapters/http/client.rb', line 27 def get(path) perform Net::HTTP::Get, path, @headers end |
#post(path, body = nil) ⇒ Object
31 32 33 |
# File 'lib/flipper/adapters/http/client.rb', line 31 def post(path, body = nil) perform Net::HTTP::Post, path, @headers, body: body end |