Documentation
¶
Index ¶
- func CloseBody(Body io.ReadCloser)
- func DoJsonGetRequest[T any](url string, params map[string]string) (*T, error)
- func DoRequest(method string, url string, requestBody []byte, params map[string]string) (*http.Response, error)
- func DoRequestBasicAuth(method string, url string, requestBody []byte, params map[string]string, ...) (*http.Response, error)
- func DoRequestBearer(method string, url string, requestBody []byte, params map[string]string, ...) (*http.Response, error)
- func IsGoodStatusCode(code int) bool
- func IsInternalError(code int) bool
- func IsUserError(code int) bool
- func ParseBody[T any](closer io.ReadCloser) (*T, error)
- func ParseJson[T any](data []byte) (*T, error)
- func ReadBody(responseBody io.ReadCloser) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseBody ¶
func CloseBody(Body io.ReadCloser)
CloseBody is a helper function that closes the body of a response
func DoJsonGetRequest ¶
func DoRequest ¶
func DoRequest(method string, url string, requestBody []byte, params map[string]string) (*http.Response, error)
DoRequest is a helper function that does a request with the given method, url, request body and params
func DoRequestBasicAuth ¶
func DoRequestBasicAuth(method string, url string, requestBody []byte, params map[string]string, username string, password string) (*http.Response, error)
DoRequestBasicAuth is a helper function that does a request with the given method, url, request body, params and basic auth
func DoRequestBearer ¶
func DoRequestBearer(method string, url string, requestBody []byte, params map[string]string, token string) (*http.Response, error)
DoRequestBearer is a helper function that does a request with the given method, url, request body, params and bearer token
func IsGoodStatusCode ¶
IsGoodStatusCode checks if the status code is a good status code, i.e. 2xx
func IsInternalError ¶
IsInternalError checks if the status code is an internal error, i.e. 5xx
func IsUserError ¶
IsUserError checks if the status code is a bad request, i.e. 4xx
func ParseBody ¶
func ParseBody[T any](closer io.ReadCloser) (*T, error)
ParseBody is a helper function that parses the body of a response into the given out object
Types ¶
This section is empty.