Class: Couch::Client
- Inherits:
-
Object
- Object
- Couch::Client
- Defined in:
- lib/couch/client.rb
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(uri) ⇒ Client
constructor
A new instance of Client.
- #request(http_method, uri, body = nil) ⇒ Object
Constructor Details
#initialize(uri) ⇒ Client
5 6 7 8 |
# File 'lib/couch/client.rb', line 5 def initialize(uri) @uri = uri @http = HTTPkit::Client.start(config) end |
Instance Method Details
#config ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/couch/client.rb', line 10 def config { address: @uri.host, port: @uri.port, ssl: @uri.scheme == 'https', handlers: [HTTPkit::Client::SSLHandler.new, HTTPkit::Client::KeepAliveHandler.new, HTTPkit::Client::TimeoutsHandler.new], timeout: 120, connect_timeout: 120 } end |
#request(http_method, uri, body = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/couch/client.rb', line 18 def request(http_method, uri, body = nil) request = Request.new(http_method, uri, {}, body) response = @http.perform(request).sync Response.build(response) end |