Documentation ¶
Overview ¶
Package utils contains common functionality needed across the Cerberus Go client
Index ¶
- Variables
- func AddClientHeader(headers http.Header) http.Header
- func CheckAndParse(resp *http.Response) (*api.UserAuthResponse, error)
- func DefaultHttpClient() *http.Client
- func NewHttpClient(defaultHeaders http.Header) *http.Client
- func ParseAPIError(r io.Reader) error
- func RoundTripperWithDefaultHeaders(rt http.RoundTripper, defaultHeaders http.Header) roundTripperWithDefaultHeaders
- func ValidateURL(fullURL string) (*url.URL, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorBodyNotReturned = fmt.Errorf("No error body returned from server")
Functions ¶
func AddClientHeader ¶
utils.AddClientHeader is a helper to create the default client headers for every request
func CheckAndParse ¶
func CheckAndParse(resp *http.Response) (*api.UserAuthResponse, error)
CheckAndParse is a helper function to check for user auth and token refresh errors and parse a response. It will return a user friendly error
func DefaultHttpClient ¶
func ParseAPIError ¶
utils.ParseAPIError is a helper for parsing an error response body from the API. If the body doesn't have an error, it will return ErrorBodyNotReturned to indicate that there was no error body sent (probably means there was a server error)
func RoundTripperWithDefaultHeaders ¶
func RoundTripperWithDefaultHeaders(rt http.RoundTripper, defaultHeaders http.Header) roundTripperWithDefaultHeaders
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.