httpclient

package
v0.0.0-...-493bf59 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertError

func ConvertError(resp *http.Response) error

ConvertError converts a known error response into a go-usable error.

func IsError

func IsError(statusCode int) bool

IsError checks if an HTTP response code is outside of the "OK" range.

func NewTLSHTTPManager

func NewTLSHTTPManager(skipVerify bool) models.HTTPManager

NewTLSHTTPManager constructs and returns a new instance of HTTPManager with TLSv1.2 and redirect support.

Types

type TLSHTTPManager

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

TLSHTTPManager is a extension of HTTPManager with explicit TLSv1.2 support.

func (*TLSHTTPManager) ConvertError

func (m *TLSHTTPManager) ConvertError(b []byte, statusCode int) (*models.Error, error)

ConvertError takes in a response from one of the httpclient methods and converts it to a usable error object.

func (*TLSHTTPManager) ConvertResp

func (m *TLSHTTPManager) ConvertResp(b []byte, statusCode int, s interface{}) error

ConvertResp takes in a resp from one of the httpclient methods and checks if it is a successful request. If not, it is parsed as an error object and returned as an error. Otherwise it will be marshalled into the requested interface. ALWAYS PASS A POINTER INTO THIS METHOD. If you don't pass a struct pointer your original object will be nil or an empty struct.

func (*TLSHTTPManager) Delete

func (m *TLSHTTPManager) Delete(body []byte, url string, headers map[string][]string) ([]byte, int, error)

Delete performs a DELETE request

func (*TLSHTTPManager) Get

func (m *TLSHTTPManager) Get(body []byte, url string, headers map[string][]string) ([]byte, int, error)

Get performs a GET request

func (*TLSHTTPManager) GetHeaders

func (m *TLSHTTPManager) GetHeaders(sessionToken, version, pod, userID string) map[string][]string

GetHeaders builds a map of headers for a new request.

func (*TLSHTTPManager) Post

func (m *TLSHTTPManager) Post(body []byte, url string, headers map[string][]string) ([]byte, int, error)

Post performs a POST request

func (*TLSHTTPManager) PostFile

func (m *TLSHTTPManager) PostFile(filepath string, url string, headers map[string][]string) ([]byte, int, error)

PostFile uploads a file with a POST

func (*TLSHTTPManager) Put

func (m *TLSHTTPManager) Put(body []byte, url string, headers map[string][]string) ([]byte, int, error)

Put performs a PUT request

func (*TLSHTTPManager) PutFile

func (m *TLSHTTPManager) PutFile(filepath string, url string, headers map[string][]string) ([]byte, int, error)

PutFile uploads a file with a PUT

Jump to

Keyboard shortcuts

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