mockhttp

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 6 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTransport = NewTransport()
View Source
var (
	ErrServerNotFound = errors.New("server not found")
)

Functions

func ListenAndServe

func ListenAndServe(host string, h http.Handler) error

ListenAndServe uses DefaultTransport to listen on a mock network address addr and handler to handle requests on incoming connections.

Types

type Transport

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

Transport is an mock implementation of RoundTripper that supports HTTP, HTTPS, and HTTP proxies (for either HTTP or HTTPS with CONNECT).

func NewTransport

func NewTransport() *Transport

NewTransport creates a new mock RoundTripper object.

func (*Transport) ListenAndServe

func (p *Transport) ListenAndServe(host string, h http.Handler) error

ListenAndServe listens on a mock network address addr and handler to handle requests on incoming connections.

func (*Transport) RoundTrip

func (p *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error)

RoundTrip executes a single HTTP transaction, returning a Response for the provided Request.

func (*Transport) SetRemoteAddr added in v1.11.7

func (p *Transport) SetRemoteAddr(remoteAddr string) *Transport

SetRemoteAddr sets the remote network address.

Jump to

Keyboard shortcuts

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