Class: Sbmt::Strangler::Http::Transport

Inherits:
Object
  • Object
show all
Includes:
Dry::Monads::Do, Dry::Monads::Result::Mixin
Defined in:
lib/sbmt/strangler/http/transport.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_options: nil) ⇒ Transport

Returns a new instance of Transport.



10
11
12
# File 'lib/sbmt/strangler/http/transport.rb', line 10

def initialize(http_options: nil)
  @http_options = http_options
end

Instance Method Details

#get_request(url, params: {}, headers: {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/sbmt/strangler/http/transport.rb', line 14

def get_request(url, params: {}, headers: {})
  with_error_handling(url) do
    response = connection.get(url, params, headers)
    Success(body: response.body, status: response.status, headers: response.headers)
  end
end

#post_request(url, body: {}, headers: {}) ⇒ Object



21
22
23
24
25
26
# File 'lib/sbmt/strangler/http/transport.rb', line 21

def post_request(url, body: {}, headers: {})
  with_error_handling(url) do
    response = connection.post(url, body, headers)
    Success(body: response.body, status: response.status, headers: response.headers)
  end
end

#put_request(url, body: {}, headers: {}) ⇒ Object



28
29
30
31
32
33
# File 'lib/sbmt/strangler/http/transport.rb', line 28

def put_request(url, body: {}, headers: {})
  with_error_handling(url) do
    response = connection.put(url, body, headers)
    Success(body: response.body, status: response.status, headers: response.headers)
  end
end