httpmock

package
v1.122.5-rc-test Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	StatusCode int
	Headers    map[string]string
	Body       string
}

Response represents a mocked HTTP response.

type Transport

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

Transport is a custom HTTP transport for handling mocked responses.

func NewClient

func NewClient() (*http.Client, *Transport)

NewClient creates an *http.Client configured to use the Transport.

func NewTransport

func NewTransport() *Transport

NewTransport creates a new instance of Transport.

func (*Transport) AddResponse

func (t *Transport) AddResponse(url string, response Response)

AddResponse registers a response for a given URL. Multiple responses for the same URL will be returned in sequence.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface.

Jump to

Keyboard shortcuts

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