httpclient

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: Apache-2.0 Imports: 18 Imported by: 1

README

httpclient

Customised http client for Go

Documentation

Index

Constants

View Source
const (
	HttpClientUnknownError            = int(httpClientUnknownError)
	HttpClientMarshallingError        = int(httpClientMarshallingError)
	HttpClientServiceUnavailableError = int(httpClientServiceUnavailableError)
	HttpClientConnectionRefusedError  = int(httpClientConnectionRefusedError)
	HttpClientRetriesExhaustedError   = int(httpClientRetriesExhaustedError)
	HttpClientHoSuchHostError         = int(httpClientHoSuchHostError)
)

Variables

This section is empty.

Functions

func NewConnectionRefusedError added in v0.0.4

func NewConnectionRefusedError(code int, err error) error

func NewHttpError

func NewHttpError(code int, err error) error

func NewServiceUnreachableError added in v0.0.4

func NewServiceUnreachableError(code int, message string) error

Types

type BreakError

type BreakError struct {
	Wait time.Duration
	Err  error
}

func (BreakError) Error

func (be BreakError) Error() string

type Client

type Client interface {
	Post(url string, data map[string]any, headers map[string]string) ([]byte, map[string]string, int, error)
	Get(url string, args map[string]any, headers map[string]string) ([]byte, map[string]string, int, error)
}

type ConnectionRefusedError added in v0.0.4

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

func (*ConnectionRefusedError) Code added in v0.0.4

func (e *ConnectionRefusedError) Code() int

func (*ConnectionRefusedError) Error added in v0.0.4

func (e *ConnectionRefusedError) Error() string

func (*ConnectionRefusedError) Is added in v0.0.4

func (e *ConnectionRefusedError) Is(tgt error) bool

type HttpClient added in v0.0.6

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

func New added in v0.0.7

func New() *HttpClient

func (*HttpClient) Get added in v0.0.6

func (c *HttpClient) Get(url string, args map[string]any, headers map[string]string) ([]byte, map[string]string, int, error)

func (*HttpClient) Post added in v0.0.6

func (c *HttpClient) Post(url string, args map[string]any, headers map[string]string) ([]byte, map[string]string, int, error)

func (*HttpClient) SkipTlsVerify added in v0.0.7

func (c *HttpClient) SkipTlsVerify() *HttpClient

func (*HttpClient) WithBasicAuth added in v0.0.8

func (c *HttpClient) WithBasicAuth(login, password string) *HttpClient

func (*HttpClient) WithBearerAuth added in v0.0.8

func (c *HttpClient) WithBearerAuth(token string) *HttpClient

func (*HttpClient) WithBreaker added in v0.0.6

func (c *HttpClient) WithBreaker(failureThreshold uint, initial, max time.Duration) *HttpClient

func (*HttpClient) WithNoAuth added in v0.0.8

func (c *HttpClient) WithNoAuth() *HttpClient

func (*HttpClient) WithRetry added in v0.0.6

func (c *HttpClient) WithRetry(retries uint, delay time.Duration) *HttpClient

func (*HttpClient) WithTimeout added in v0.0.6

func (c *HttpClient) WithTimeout(timeout time.Duration) *HttpClient

type HttpError

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

func (*HttpError) Code

func (e *HttpError) Code() int

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) Is

func (e *HttpError) Is(tgt error) bool

type ServiceCall

type ServiceCall func(
	client *http.Client, ctx context.Context, url string,
	args map[string]any, headers map[string]string) ([]byte, map[string]string, int, error)

type ServiceUnreachableError added in v0.0.4

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

func (*ServiceUnreachableError) Code added in v0.0.4

func (e *ServiceUnreachableError) Code() int

func (*ServiceUnreachableError) Error added in v0.0.4

func (e *ServiceUnreachableError) Error() string

func (*ServiceUnreachableError) Is added in v0.0.4

func (e *ServiceUnreachableError) Is(tgt error) bool

Jump to

Keyboard shortcuts

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