rest

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2016 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConnectionFailed = errors.New("Cannot connect to the server.")

ErrConnectionFailed is an error raised when the connection between the client and server failed.

Functions

func ParseHost

func ParseHost(host string) (string, string, string, error)

ParseHost verifies that the given host strings is valid.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the API client that performs all operations against a docker server.

func NewClient

func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error)

NewClient initializes a new API client for the given host and API version. It won't send any version information if the version number is empty. It uses the given http client as transport. It also initializes the custom http headers to add to each request.

func (*Client) AddCustomHeader

func (cli *Client) AddCustomHeader(name, value string)

Add a custom header.

func (*Client) ClientVersion

func (cli *Client) ClientVersion() string

ClientVersion returns the version string associated with this instance of the Client.

func (*Client) Delete

func (cli *Client) Delete(ctx context.Context, path string, query url.Values, headers map[string][]string) (*ServerResponse, error)

Delete sends an http request to the API server using the method DELETE

func (*Client) Get

func (cli *Client) Get(ctx context.Context, path string, query url.Values, headers map[string][]string) (*ServerResponse, error)

Get sends an http request to the API server using the method GET.

func (*Client) Head

func (cli *Client) Head(ctx context.Context, path string, query url.Values, headers map[string][]string) (*ServerResponse, error)

Head sends an http request to the API server using the method HEAD.

func (*Client) Post

func (cli *Client) Post(ctx context.Context, path string, query url.Values, obj interface{}, headers map[string][]string) (*ServerResponse, error)

Post sends an http request to the API server using the method POST

func (*Client) PostRaw

func (cli *Client) PostRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (*ServerResponse, error)

func (*Client) Put

func (cli *Client) Put(ctx context.Context, path string, query url.Values, obj interface{}, headers map[string][]string) (*ServerResponse, error)

Put sends an http request to the API server using the method PUT

func (*Client) PutRaw

func (cli *Client) PutRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (*ServerResponse, error)

func (*Client) RemoveCustomHeader

func (cli *Client) RemoveCustomHeader(name string)

Remove a custom header.

func (*Client) UpdateClientVersion

func (cli *Client) UpdateClientVersion(v string)

UpdateClientVersion updates the version string associated with this instance of the Client.

type ServerError

type ServerError struct {
	// contains filtered or unexported fields
}

A error that contains error messages returned from API server.

func (ServerError) Error

func (se ServerError) Error() string

func (ServerError) RawError

func (se ServerError) RawError() []byte

func (ServerError) StatusCode

func (se ServerError) StatusCode() int

type ServerResponse

type ServerResponse struct {
	Body       io.ReadCloser
	Header     http.Header
	StatusCode int
}

serverResponse is a wrapper for http API responses.

func (*ServerResponse) EnsureClosed

func (response *ServerResponse) EnsureClosed()

Directories

Path Synopsis
cancellable
Package cancellable provides helper function to cancel http requests.
Package cancellable provides helper function to cancel http requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL