utils

package
v3.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package utils contains common functionality needed across the Cerberus Go client

Index

Constants

This section is empty.

Variables

View Source
var ErrorBodyNotReturned = fmt.Errorf("No error body returned from server")

Functions

func AddClientHeader

func AddClientHeader(headers http.Header) http.Header

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 DefaultHttpClient() *http.Client

func NewHttpClient

func NewHttpClient(defaultHeaders http.Header) *http.Client

func ParseAPIError

func ParseAPIError(r io.Reader) error

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

func ValidateURL

func ValidateURL(fullURL string) (*url.URL, error)

ValidateURL takes a cerberus URL and makes sure that it is valid. It expects

Types

This section is empty.

Jump to

Keyboard shortcuts

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