http

package
v1.19.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 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

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