httpmock

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathOnly matchType = iota
	HostOnly
	FullURL
	HostAndPath
	PathAndQuerystring
)

Variables

This section is empty.

Functions

func MatchAny

func MatchAny(*http.Request) bool

Types

type Matcher

type Matcher func(req *http.Request) bool

type Mocker

type Mocker struct {
	Requests []*http.Request
	MatchURL matchType // if false, only matches the path and if true, matches full url
	// contains filtered or unexported fields
}

func New

func New() *Mocker

func (*Mocker) RegisterResponder

func (r *Mocker) RegisterResponder(method, path string, resp Responder)

func (*Mocker) RoundTrip

func (r *Mocker) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies http.RoundTripper

func (*Mocker) Verify

func (r *Mocker) Verify(t Testing)

type Responder

type Responder func(req *http.Request) (*http.Response, error)

func NewFileResponse

func NewFileResponse(status int, filename string) Responder

func NewJSONResponse

func NewJSONResponse(status int, body interface{}) Responder

func NewStringResponse

func NewStringResponse(status int, body string) Responder

type Stub

type Stub struct {
	Matcher   Matcher
	Responder Responder
	// contains filtered or unexported fields
}

type Testing

type Testing interface {
	Errorf(string, ...interface{})
	Helper()
}

Jump to

Keyboard shortcuts

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