httptrick

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OverrideCacheControl

func OverrideCacheControl(age time.Duration) string

OverrideCacheControl creates a value that overrides the Cache-Control header.

Types

type InterceptFullFunc

type InterceptFullFunc func(*http.Request, func() (*http.Response, error)) (*http.Response, error)

InterceptFullFunc is the full version of InterceptFunc: the next callback also returns a response.

type InterceptFunc

type InterceptFunc func(*http.Request, func() error) error

InterceptFunc is a function for intercepting a request. The request being intercepted is given, as well as a callback that triggers the actual request.

type Interceptor

type Interceptor struct {
	// contains filtered or unexported fields
}

Interceptor wraps around an existing roundtripper and calls the registered callbacks on each request.

func WrapInterceptor

func WrapInterceptor(c http.RoundTripper) *Interceptor

WrapInterceptor wraps the given RoundTripper inside a Interceptor.

func (*Interceptor) AddIntercept

func (r *Interceptor) AddIntercept(f InterceptFunc) func()

AddIntercept adds the given callback. The callback is called when RoundTrip is called.

func (*Interceptor) AddInterceptFull

func (r *Interceptor) AddInterceptFull(f InterceptFullFunc) func()

AddIntercept adds the given callback. The callback is called when RoundTrip is called.

func (*Interceptor) RoundTrip

func (r *Interceptor) RoundTrip(req *http.Request) (*http.Response, error)

type RoundTripWrapper

type RoundTripWrapper struct {
	Old http.RoundTripper
	F   func(*http.Request, *http.Response)
}

RoundTripWrapper wraps a http.RoundTripper for debugging.

func (RoundTripWrapper) RoundTrip

func (c RoundTripWrapper) RoundTrip(req *http.Request) (*http.Response, error)

type TransportHeaderOverride

type TransportHeaderOverride struct {
	R http.RoundTripper
	H map[string]map[string]string
}

TransportHeaderOverride overrides the header of all incoming responses matching the path inside the map. It is used for caching.

func (TransportHeaderOverride) RoundTrip

func (t TransportHeaderOverride) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL