http

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureKeysAreFilled

func EnsureKeysAreFilled(m map[string]interface{}, keys ...string) error

EnsureKeysAreFilled ensures that the given object (usually parsed from JSON) has the given keys and that given keys are not empty (all blank space)

func GetRequestAPIToken

func GetRequestAPIToken(req *http.Request, headerName string) (string, error)

GetRequestAPIToken gets the API token from the given header

func GetRequestAuthorizationToken

func GetRequestAuthorizationToken(req *http.Request) (string, error)

GetRequestAuthorizationToken gets a bearer token from either headers or cookies, or an error if it is contained in neither

func GetRequestTokenCookie

func GetRequestTokenCookie(req *http.Request) (string, error)

GetRequestTokenCookie gets a token of the specified type ("Bearer", "Basic") from the cookies of a request

func GetRequestTokenHeader

func GetRequestTokenHeader(header http.Header, tokenType string) (string, error)

GetRequestTokenHeader gets a token of the specified type ("Bearer", "Basic") from the headers of a request

func ParseBodyToMap

func ParseBodyToMap(r *http.Request) (map[string]interface{}, error)

ParseBodyToMap parses a JSON body to map[string]interface{}, returning either an Internal Server Error or Bad Request Error on failure (depending on the issue)

func ParseResponseBodyToMap

func ParseResponseBodyToMap(r *http.Response) (map[string]interface{}, error)

ParseResponseBodyToMap parses a JSON body to map[string]interface{}, returning either an Internal Server Error or Bad Request Error on failure (depending on the issue)

func ReadBody

func ReadBody(r *http.Request) ([]byte, error)

ReadBody reads all contents of a given request body, returning an Internal Server Error if it fails

func ReadResponseBody

func ReadResponseBody(r *http.Response) ([]byte, error)

ReadResponseBody reads all contents of a given response body

func RestyGet

func RestyGet(result interface{}, request *resty.Request, url string) (interface{}, error)

RestyGet performs a GET request and places the parsed JSON result in

Types

type DebugTransport

type DebugTransport struct {
	Tripper http.RoundTripper
}

DebugTransport is used to print extra debug messages during http client calls

func (DebugTransport) RoundTrip

func (d DebugTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip handles a request for the DebugTransport

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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