package intercept

import "cmd/go/internal/web/intercept"

Index

Variables

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.

Source Files

intercept.go

Version
v1.24.0
Published
Feb 10, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
59 seconds ago

Tools for package owners.