requestutils

package
v0.0.0-...-e71a76f Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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 DoJsonGetRequest[T any](url string, params map[string]string) (*T, error)

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

func IsGoodStatusCode(code int) bool

IsGoodStatusCode checks if the status code is a good status code, i.e. 2xx

func IsInternalError

func IsInternalError(code int) bool

IsInternalError checks if the status code is an internal error, i.e. 5xx

func IsUserError

func IsUserError(code int) bool

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

func ParseJson

func ParseJson[T any](data []byte) (*T, error)

ParseJson is a helper function that parses json data into the given out object

func ReadBody

func ReadBody(responseBody io.ReadCloser) ([]byte, error)

ReadBody is a helper function that reads the body of a response

Types

This section is empty.

Jump to

Keyboard shortcuts

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