utils

package
v0.0.0-...-8568aec Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2017 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = utils.StdClient()

DefaultClient is a web-utils.SafeClient instance for the whole project's usage.

Functions

func GetAddress

func GetAddress(v interface{}) string

func IsNil

func IsNil(object interface{}) bool

func ObjectsAreEqual

func ObjectsAreEqual(expected, actual interface{}) bool

func PrintlnJson

func PrintlnJson(v interface{})

PrintlnJson helps debugging JSON APIs.

Types

type Assert

type Assert struct {
	// contains filtered or unexported fields
}

func NewAssert

func NewAssert(t testing.TB) *Assert

func (*Assert) Equal

func (a *Assert) Equal(expected, actual interface{}, msg string)

func (*Assert) Nil

func (a *Assert) Nil(obj interface{}, msg string)

func (*Assert) NoError

func (a *Assert) NoError(err error, msg string)

func (*Assert) NotEqual

func (a *Assert) NotEqual(expected, actual interface{}, msg string)

func (*Assert) NotNil

func (a *Assert) NotNil(obj interface{}, msg string)

func (*Assert) True

func (a *Assert) True(cond bool, msg string)

type HTTPClient

type HTTPClient interface {
	HTTPRequester
	HTTPJsonPoster
	HTTPFormPoster
}

HTTPClient wraps HTTP* interfaces.

type HTTPFormPoster

type HTTPFormPoster interface {
	PostFormWithRetry(url string, v url.Values, maxTries int, f utils.RequestHook) (tries, status int, body []byte, err error)
}

HTTPFormPoster is one of the "reversed" interface of web-utils.SafeClient for better unit tests; use it for POST requests (default to plain/text).

type HTTPJsonPoster

type HTTPJsonPoster interface {
	PostJsonWithRetry(url string, v interface{}, maxTries int, f utils.RequestHook) (tries, status int, body []byte, err error)
}

HTTPJsonPoster is one of the "reversed" interface of web-utils.SafeClient for better unit tests; use it for POST requests with JSON payload.

type HTTPRequester

type HTTPRequester interface {
	RequestWithRetry(req *http.Request, maxTries int) (tries, status int, body []byte, err error)
}

HTTPRequester is one of the "reversed" interface of web-utils.SafeClient for better unit tests; use it for GET requests.

Jump to

Keyboard shortcuts

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