utils

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const PKG_VERSION = "v2.1.0"

Variables

This section is empty.

Functions

func HandleRecovered

func HandleRecovered(r interface{}, logger *logrus.Logger) (err error)

HandleRecovered logs a recovered panic

Types

type HTTPClient

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

HTTPClient represents the HTTPClient infos

func NewHTTPClient

func NewHTTPClient(baseURL string, options HTTPOptions) *HTTPClient

NewHTTPClient creates an HTTP requester object

func (*HTTPClient) Call

func (r *HTTPClient) Call(path, method string, body []byte, headers map[string]string) (*HTTPResponse, error)

Call executes request with retries and returns response body, headers, status code and error

type HTTPClientInterface added in v2.1.0

type HTTPClientInterface interface {
	Call(path, method string, body []byte, headers map[string]string) (*HTTPResponse, error)
}

HTTPClientInterface represents an interface for HTTP caller

func NewHTTPClientMock added in v2.1.0

func NewHTTPClientMock(responseCode int, responseBody []byte, responseHeaders http.Header) HTTPClientInterface

NewHTTPClientMock creates an HTTP mock object

type HTTPClientMock added in v2.1.0

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

HTTPClientMock represents the HTTPClientMock infos

func (*HTTPClientMock) Call added in v2.1.0

func (r *HTTPClientMock) Call(path, method string, body []byte, headers map[string]string) (*HTTPResponse, error)

Call executes request with retries and returns response body, headers, status code and error

type HTTPOptions

type HTTPOptions struct {
	Retries int
	Timeout time.Duration
	Headers map[string]string
}

HTTPOptions represents the options for the HTTPRequest object

type HTTPResponse

type HTTPResponse struct {
	Body       []byte
	Headers    http.Header
	StatusCode int
}

HTTPResponse represents the HTTPResponse infos

Jump to

Keyboard shortcuts

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