util

package
v0.2.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserAgentHeader = fmt.Sprintf("Promoter/%s", version.Version)

Functions

func Drain

func Drain(r *http.Response)

Drain consumes and closes the response's body to make sure that the HTTP client can reuse existing connections.

func Get

func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error)

Get sends a GET request to the given URL

func PostJSON

func PostJSON(ctx context.Context, client *http.Client, url string, body io.Reader) (*http.Response, error)

PostJSON sends a POST request with JSON payload to the given URL.

func PostText

func PostText(ctx context.Context, client *http.Client, url string, body io.Reader) (*http.Response, error)

PostText sends a POST request with text payload to the given URL.

func RedactURL

func RedactURL(err error) error

RedactURL removes the URL part from an error of *url.Error type.

func UploadFile

func UploadFile(accessKey, secretKey, endpoint, bucket, region string, plot io.WriterTo) (string, error)

Types

type MultiError

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

MultiError contains multiple errors and implements the error interface. Its zero value is ready to use. All its methods are goroutine safe.

func (*MultiError) Add

func (e *MultiError) Add(err error)

Add adds an error to the MultiError.

func (*MultiError) Error

func (e *MultiError) Error() string

func (*MultiError) Errors

func (e *MultiError) Errors() []error

Errors returns the errors added to the MuliError. The returned slice is a copy of the internal slice of errors.

func (*MultiError) Len

func (e *MultiError) Len() int

Len returns the number of errors added to the MultiError.

Jump to

Keyboard shortcuts

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