intercept

Imports

Imports #

"errors"
"net/http"
"net/url"

Constants & Variables

TestHooksEnabled var #

TestHooksEnabled is true if interceptors are installed

var TestHooksEnabled = false

testInterceptors var #

var testInterceptors []Interceptor

Structs

Interceptor struct #

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
}

Functions

DisableTestHooks function #

DisableTestHooks disables the installed interceptors.

func DisableTestHooks()

EnableTestHooks function #

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

func EnableTestHooks(interceptors []Interceptor) error

Request function #

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

func Request(req *http.Request)

URL function #

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

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

Generated with Arrow