http

package
v2.0.437+incompatible Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: AGPL-3.0 Imports: 8 Imported by: 14

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(host string, timeout time.Duration, defaultHeaders ...HeaderValue) (Client, error)

NewClient 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.

Jump to

Keyboard shortcuts

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