http_wrapper

package module
v0.0.0-...-12fe155 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

http-wrapper-go

license

A light wrapper over Go's HTTP client

Detailed explanation: https://medium.com/codealchemist/a-lightweight-wrapper-over-gos-http-client-1b915e7de564

Documentation

Index

Constants

View Source
const (
	NOT_ASSIGNED                              = ""
	DEFAULT_TIMEOUT                           = 20 * time.Second
	AUTHORIZATION_TOKEN_PREFIX                = "Token"
	CONTENT_TYPE_APP_JSON         ContentType = "application/json"
	CONTENT_TYPE_FORM_URL_ENCODED ContentType = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

func MakeApiCall

func MakeApiCall(ctx context.Context, request *HttpRequestParams, responseAddr interface{}) (customError error.CustomError)

responseAddr is the the address of the struct to put the api response

func MakeApiCallWithRawResponse

func MakeApiCallWithRawResponse(ctx context.Context, request *HttpRequestParams) (body []byte, customError error.CustomError)

func MakeApiCallWithRetries

func MakeApiCallWithRetries(ctx context.Context, request *HttpRequestParams, responseAddr interface{}, retriesCount int) (customError error.CustomError)

Types

type ContentType

type ContentType string

type HttpRequestParams

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

func NewHttpRequestParams

func NewHttpRequestParams(endpoint string, method string) *HttpRequestParams

func (*HttpRequestParams) AddHeader

func (a *HttpRequestParams) AddHeader(key, val string)

func (*HttpRequestParams) AddQueryParam

func (a *HttpRequestParams) AddQueryParam(key, val string)

func (*HttpRequestParams) BasicAuth

func (a *HttpRequestParams) BasicAuth() string

func (*HttpRequestParams) Host

func (a *HttpRequestParams) Host() string

func (*HttpRequestParams) SetAuth

func (a *HttpRequestParams) SetAuth(username string, password string)

func (*HttpRequestParams) SetAuthPassword

func (a *HttpRequestParams) SetAuthPassword(authPassword string)

func (*HttpRequestParams) SetAuthToken

func (a *HttpRequestParams) SetAuthToken(authToken string)

func (*HttpRequestParams) SetAuthUserName

func (a *HttpRequestParams) SetAuthUserName(authUserName string)

func (*HttpRequestParams) SetBasicAuth

func (a *HttpRequestParams) SetBasicAuth(basicAuth string)

func (*HttpRequestParams) SetBody

func (a *HttpRequestParams) SetBody(requestBody interface{})

func (*HttpRequestParams) SetContentType

func (a *HttpRequestParams) SetContentType(contentType ContentType)

func (*HttpRequestParams) SetHost

func (a *HttpRequestParams) SetHost(host string)

func (*HttpRequestParams) SetQueryParams

func (a *HttpRequestParams) SetQueryParams(requestQueryParams map[string]string)

func (*HttpRequestParams) SetTimeout

func (a *HttpRequestParams) SetTimeout(timeout time.Duration)

Jump to

Keyboard shortcuts

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