...

Package intercept

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

Overview ▾

Variables

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

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.

type Interceptor

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

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

func URL

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

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