net

package
v0.0.0-...-5b64428 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestBodyBytes

func RequestBodyBytes(request *http.Request) *bytes.Buffer

RequestBodyBytes reads the body from a request into a bytes.Buffer, resets the request Body and returns the buffer.

Types

type ContextAwareHttpClient

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

func NewContextAwareHttpClient

func NewContextAwareHttpClient(doer HttpDoer) *ContextAwareHttpClient

func (*ContextAwareHttpClient) Do

type DetailedErrorResponse

type DetailedErrorResponse struct {
	Errors   []map[string]interface{} `json:"errors"`
	Type     string                   `json:"type"`
	Title    string                   `json:"title"`
	Status   int                      `json:"status"`
	Instance string                   `json:"instance"`
	Detail   string                   `json:"detail"`
}

func (*DetailedErrorResponse) Error

func (e *DetailedErrorResponse) Error() string

type ErrorChecker

type ErrorChecker struct{}

func (*ErrorChecker) CheckForErrors

func (c *ErrorChecker) CheckForErrors(response *http.Response) error

type HttpDoer

type HttpDoer interface {
	Do(request *http.Request) (*http.Response, error)
}

type ResponseChecker

type ResponseChecker interface {
	CheckForErrors(response *http.Response) error
}

type RetryingHttpClient

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

RetryingHttpClient is an HttpDoer decorator that retries HTTP requests for any response with HTTP status 500+, or any network error.

func NewRetryingHttpClient

func NewRetryingHttpClient(wrappedClient HttpDoer, retryAttempts int, multiplier float64) *RetryingHttpClient

func (*RetryingHttpClient) Do

func (h *RetryingHttpClient) Do(request *http.Request) (*http.Response, error)

type UserAgentHttpClient

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

UserAgentHttpClient is an HttpDoer decorator that sets the "User-Agent" HTTP header on requests.

func NewUserAgentHttpClient

func NewUserAgentHttpClient(wrapper HttpDoer, userAgent string) *UserAgentHttpClient

func (*UserAgentHttpClient) Do

func (h *UserAgentHttpClient) Do(request *http.Request) (*http.Response, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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