mockhttp

package
v1.13.10 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

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