httpclient

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an HTTP client

func New

func New(opts ...Opt) *Client

New returns a new HTTP client

func (*Client) Get

func (c *Client) Get(url string, opts ...RequestOpt) (*HTTPResponse, error)

Get put an HTTP GET request

func (*Client) Post

func (c *Client) Post(url string, req []byte, opts ...RequestOpt) (*HTTPResponse, error)

Post posts an HTTP request

type HTTPResponse

type HTTPResponse struct {
	StatusCode  int
	Payload     []byte
	ErrorMsg    string
	ContentType string
}

HTTPResponse contains an HTTP response

type Opt

type Opt func(c *Client)

Opt defines an option for the HTTP client

func WithTransport

func WithTransport(rt http.RoundTripper) Opt

WithTransport sets the transport for the client. This is usually only set for unit tests.

type RequestOpt

type RequestOpt func(opts *requestOptions)

RequestOpt sets a request option

func WithAuthToken

func WithAuthToken(token string) RequestOpt

WithAuthToken sets an authorization token in the header

Jump to

Keyboard shortcuts

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