testhelpers

package
v0.0.0-...-67058d9 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIP

func GetLocalIP() (string, error)

GetLocalIP gets the non-loopback IP address of this host.

func MakeTestServer

func MakeTestServer(t *testing.T, h http.Handler, opts ...TestServerOption) *httptest.Server

Types

type ProxyHandler

type ProxyHandler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ProxyHandler is a http.Handler that implements a simple HTTP proxy server.

func (*ProxyHandler) Count

func (p *ProxyHandler) Count() int

Count returns the number of requests that have been proxied.

func (*ProxyHandler) Reset

func (p *ProxyHandler) Reset()

Reset sets the counter for proxied requests to zero.

func (*ProxyHandler) ServeHTTP

func (p *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP only accepts the CONNECT verb and will tunnel your connection to the specified host. Also tracks the number of connections that it proxies for debugging purposes.

type TestServerOption

type TestServerOption func(*testing.T, *httptest.Server)

func WithTestServerAddress

func WithTestServerAddress(ip string) TestServerOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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