Documentation ¶
Index ¶
- func AppendQueryParams(rawUrl string, queryParams map[string]string) (string, error)
- func Fetch(rawUrl string, options FetchOptions) (*http.Response, error)
- func FetchFile(raw_url string, options FetchOptions, directory, filename string) (string, error)
- func FetchJson[OUTPUT_TYPE any](rawUrl string, options FetchOptions) (OUTPUT_TYPE, error)
- func FetchString(rawUrl string, options FetchOptions) (string, error)
- func IsBadResponseWithCode(err error, code int) bool
- func JsonToReader(input any) io.Reader
- func LogPossibleFetchError(err error) bool
- func LogResponseDetails(response *http.Response)
- func ReadJson[OUTPUT_TYPE any](r io.Reader) (OUTPUT_TYPE, error)
- func ReadJsonString[OUTPUT_TYPE any](input string) (OUTPUT_TYPE, error)
- func ReadString(r io.Reader) (string, error)
- func ResponseOk(response *http.Response) (bool, error)
- type BadResponseError
- type FetchError
- type FetchOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendQueryParams ¶
func Fetch ¶
func Fetch(rawUrl string, options FetchOptions) (*http.Response, error)
Fetch simplifies common http requests and associated error checking
func FetchFile ¶
func FetchFile(raw_url string, options FetchOptions, directory, filename string) (string, error)
FetchFile simplifies the common task of downloading a file from a url, returning the file's location if filename does not contain an extension, an attempt will be made to infer it from the request's Content-Type header
func FetchJson ¶
func FetchJson[OUTPUT_TYPE any](rawUrl string, options FetchOptions) (OUTPUT_TYPE, error)
FetchJson simplifies the common task of making a HTTP request to fetch some JSON data and returning it as a struct
func FetchString ¶
func FetchString(rawUrl string, options FetchOptions) (string, error)
FetchString simplifies the common task of making a HTTP request to fetch some plaintext data
func IsBadResponseWithCode ¶
a helper function to simplify checking HTTP status codes from potentially-wrapped errors
func JsonToReader ¶
JsonToReader simplifies marshalling a struct to json for use in http requests (which accept io.Reader instead of []byte)
func LogPossibleFetchError ¶
func LogResponseDetails ¶
func ReadJsonString ¶
Types ¶
type BadResponseError ¶
type BadResponseError struct {
StatusCode int
}
func (BadResponseError) Error ¶
func (e BadResponseError) Error() string
type FetchError ¶
func (FetchError) Error ¶
func (e FetchError) Error() string
func (FetchError) Unwrap ¶
func (e FetchError) Unwrap() error