Class: Docker::API::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/docker/api/connection.rb

Overview

Connection class.

Instance Method Summary collapse

Constructor Details

#initialize(url = nil, params = nil) ⇒ Connection

Create an Excon connection.

Parameters:

  • url (String) (defaults to: nil)

    : URL for the connection.

  • params (String) (defaults to: nil)

    : Additional parameters.



23
24
25
26
# File 'lib/docker/api/connection.rb', line 23

def initialize url = nil, params = nil
    return @connection = Excon.new('unix:///', {socket: '/var/run/docker.sock'}) unless url
    @connection = Excon.new(url, params || {})
end

Instance Method Details

#request(params) ⇒ Object

Call an Excon request and returns a Docker::API::Response object.

Parameters:

  • params (Hash)

    : Request parameters.



12
13
14
15
16
# File 'lib/docker/api/connection.rb', line 12

def request params
    response = Docker::API::Response.new(@connection.request(params).data)
    p response if Docker::API::PRINT_RESPONSE_TO_STDOUT 
    response
end