Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Get(url string, output interface{}, headers ...HeaderValue) ([]byte, error)
	Post(url string, body []byte, output interface{}, headers ...HeaderValue) ([]byte, error)
}

    Client represents an HTTP client which can be used for issuing requests concurrently.

    func NewClient

    func NewClient(timeout time.Duration, defaultHeaders ...HeaderValue) (Client, error)

      NewClient creates a new HTTP Client which does not perform any load balancing.

      func NewHostClient

      func NewHostClient(host string, timeout time.Duration, defaultHeaders ...HeaderValue) (Client, error)

        NewHostClient creates a new HTTP Client for the provided host. This will use round-robin to load-balance the requests to the addresses resolved by the host.

        type HeaderValue

        type HeaderValue struct {
        	Header string
        	Value  string
        }

          HeaderValue represents a header with a value attached.

          func NewHeader

          func NewHeader(header, value string) HeaderValue

            NewHeader builds an HTTP header with a value.

            type MockClient

            type MockClient struct {
            	mock.Mock
            }

              MockClient is a mock implementation of Client

              func NewMockClient

              func NewMockClient() *MockClient

                NewMockClient returns a mock implementation of Client

                func (*MockClient) Get

                func (mock *MockClient) Get(url string, output interface{}, headers ...HeaderValue) ([]byte, error)

                  Get issues an HTTP Get on a specified URL and decodes the payload as JSON.

                  func (*MockClient) Post

                  func (mock *MockClient) Post(url string, body []byte, output interface{}, headers ...HeaderValue) ([]byte, error)

                    Post is a utility function which marshals and issues an HTTP post on a specified URL.

                    Source Files