internal

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPBodyFragment

func HTTPBodyFragment(body map[string]interface{}, key string, val interface{})

HTTPBodyFragment will add a new fragment to the HTTP request body.

func HTTPFetch

func HTTPFetch(model interface{}, opts ...func(*httpFetchConfigs)) error

HTTPFetch will make an HTTP request given a http.Client and a partially formatted http.Request, it will then try to edecode the model.

func HTTPNewRequest

func HTTPNewRequest(method, url string, encoder Encoder) (*http.Request, error)

HTTPNewRequest will return a new request. If the options are set, this function will encode a body if possible.

func HTTPQueryEncodeBool

func HTTPQueryEncodeBool(req *http.Request, key string, val *bool)

HTTPQueryEncodeBool will convert a bool pointer into a string and then add it to the query parameters of an HTTP request's URL.

func HTTPQueryEncodeInt

func HTTPQueryEncodeInt(req *http.Request, key string, val *int)

HTTPQueryEncodeInt will convert an Int pointer into a string and then add it to the query parameters of an HTTP request's URL.

func HTTPQueryEncodeInt32

func HTTPQueryEncodeInt32(req *http.Request, key string, val *int32)

HTTPQueryEncodeInt32 will convert an Int32 pointer into a string and then add it to the query parameters of an HTTP request's URL.

func HTTPQueryEncodeString

func HTTPQueryEncodeString(req *http.Request, key string, val *string)

HTTPQueryEncodeString will convert an String pointer into a string and then add it to the query parameters of an HTTP request's URL.

func HTTPQueryEncodeStringer

func HTTPQueryEncodeStringer(req *http.Request, key string, val stringer)

HTTPQueryEncodeStringer will convert a stringer type into a string and then add it to the query parameters of an HTTP request's URL.

func HTTPQueryEncodeStrings

func HTTPQueryEncodeStrings(req *http.Request, key string, val []string)

HTTPQueryEncodeStringSlice will convert a slice of strings into a string and then add it to the query parameters of an HTTP request's URL.

func HTTPQueryEncodeTime

func HTTPQueryEncodeTime(req *http.Request, key string, val *time.Time)

HTTPQueryEncodeTime will convert a time.Time type into a string and then add it to the query parameters of an HTTP request's URL.

func HTTPQueryEncodeUint8

func HTTPQueryEncodeUint8(req *http.Request, key string, val *uint8)

HTTPQueryEncodeUint8 will convert auint type into a string and then add it to the query parameters of an HTTP request's URL.

func HTTPWithCallback

func HTTPWithCallback(clbk func(uint8, http.Response) error) func(*httpFetchConfigs)

HTTPWithCallback will set a callback function that takes a uint8 argument and returns an error.

func HTTPWithClient

func HTTPWithClient(client http.Client) func(*httpFetchConfigs)

HTTPWithClient will set the http client on the fetch configurations.

func HTTPWithEncoder

func HTTPWithEncoder(enc Encoder) func(*httpFetchConfigs)

HTTPWithEncoder will set the encoder for the http request body and query params.

func HTTPWithEndpoint

func HTTPWithEndpoint(ep endpoint) func(*httpFetchConfigs)

HTTPWithEndpoint will set the endpoint data for the request on the configurations.

func HTTPWithParams

func HTTPWithParams(params map[string]string) func(*httpFetchConfigs)

HTTPWithParams will set the query parameters for the request on the configurations.

func HTTPWithRatelimiter

func HTTPWithRatelimiter(rl *rate.Limiter) func(*httpFetchConfigs)

HTTPWithRatelimiter will set the rate limiting mechanism on the fetch configurations.

func HTTPWithRequest

func HTTPWithRequest(req *http.Request) func(*httpFetchConfigs)

HTTPWithRequest will set the http request on the fetch configurations.

Types

type Client

type Client interface {
	Self() *http.Client

	// RateLimiter will try to prevent 429 errors. Consistenly hitting 429 might result in an API ban.
	RateLimiter() *rate.Limiter
}

type Encoder

type Encoder interface {
	EncodeBody() (io.Reader, error)
	EncodeQuery(*http.Request)
}

Encoders are optional data than can be encoded into a request's URL or Body.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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