httpmock

package
v1.63.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 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

This section is empty.

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) RegisterResponderWithBody

func (r *Mocker) RegisterResponderWithBody(method, path, body 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 any) Responder

func NewStringResponse

func NewStringResponse(status int, body string) Responder

func NewStringResponseWithHeader

func NewStringResponseWithHeader(status int, body string, header http.Header) Responder

type Stub

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

type Testing

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

Jump to

Keyboard shortcuts

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