intercept

package standard library
go1.25.4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ( // TestHooksEnabled is true if interceptors are installed TestHooksEnabled = false )

Functions

func DisableTestHooks

func DisableTestHooks()

DisableTestHooks disables the installed interceptors.

func EnableTestHooks

func EnableTestHooks(interceptors []Interceptor) error

EnableTestHooks installs the given interceptors to be used by URL and Request.

func Request

func Request(req *http.Request)

Request updates the host to actually use for the request, if it is to be intercepted.

Types

type Interceptor

type Interceptor struct { Scheme string FromHost string ToHost string Client *http.Client }

Interceptor is used to change the host, and maybe the client, for a request to point to a test host.

func URL

func URL(u *url.URL) (*Interceptor, bool)

URL returns the Interceptor to be used for a given URL.