Class: Proc::Http::Client
- Inherits:
-
Object
- Object
- Proc::Http::Client
- Includes:
- Is::Async
- Defined in:
- lib/proc/http/client.rb
Instance Method Summary collapse
- #call(method, uri, params: {}, headers: {}, body: nil) ⇒ Object
- #close ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
18 19 20 |
# File 'lib/proc/http/client.rb', line 18 def initialize @internet = Async::HTTP::Internet.new end |
Instance Method Details
#call(method, uri, params: {}, headers: {}, body: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/proc/http/client.rb', line 22 def call(method, uri, params: {}, headers: {}, body: nil) request = Request.new(method: method, uri: uri, params: params, headers: headers, body: body) await { begin response = make_request(request) yield response ensure response&.close end } end |
#close ⇒ Object
36 37 38 |
# File 'lib/proc/http/client.rb', line 36 def close @internet.close end |