Help us shape the future of Go! Take the 2026 Go Developer Survey

http

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotFoundURL added in v1.19.0

func NotFoundURL(t *testing.T) string

NotFoundURL returns the base URL of a local server that answers 404 to every request until the test ends. Use it for a resource that must point at an endpoint which fails at once and never leaves the machine: a public host can be slow or unreachable on a CI runner, and a closed local port takes seconds to refuse on Windows.

Types

type HTTP

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

HTTP is a HTTP server that can be used in integration tests.

func New

func New(t *testing.T, fopts ...Option) *HTTP

func (*HTTP) Cleanup

func (h *HTTP) Cleanup(t *testing.T)

func (*HTTP) Port

func (h *HTTP) Port() int

func (*HTTP) Run

func (h *HTTP) Run(t *testing.T, ctx context.Context)

type Option

type Option func(*options)

Option is a function that configures the process.

func WithHandler

func WithHandler(handler http.Handler) Option

func WithHandlerFunc added in v1.13.0

func WithHandlerFunc(path string, fn http.HandlerFunc) Option

func WithMTLS added in v1.13.0

func WithMTLS(t *testing.T, ca, cert, key []byte) Option

func WithPort added in v1.15.10

func WithPort(port int) Option

func WithTLS

func WithTLS(t *testing.T, cert, key []byte) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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