proxy

package
v0.0.0-...-c283e9f Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2021 License: BSD-3-Clause Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// StickyCookieName is the name of the sticky cookie
	StickyCookieName = "_backend"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendListFunc

type BackendListFunc func() []*router.Backend

BackendListFunc returns a slice of backends

type RequestTrace

type RequestTrace struct {
	Backend *router.Backend

	ReusedConn     bool
	WasIdleConn    bool
	ConnectStart   time.Time
	ConnectDone    time.Time
	HeadersWritten time.Time
	BodyWritten    time.Time
	FirstByte      time.Time
	// contains filtered or unexported fields
}

func (*RequestTrace) Finalize

func (r *RequestTrace) Finalize(backend *router.Backend)

Finalize safely finalizes the trace for read access.

type RequestTracker

type RequestTracker interface {
	TrackRequestStart(backend string)
	TrackRequestDone(backend string)
}

type ReverseProxy

type ReverseProxy struct {

	// FlushInterval specifies the flush interval
	// to flush to the client while copying the
	// response body.
	// If zero, no periodic flushing is done.
	FlushInterval time.Duration

	RequestTracker RequestTracker

	// Logger is the logger for the proxy.
	Logger log15.Logger

	Error503Page []byte
	// contains filtered or unexported fields
}

ReverseProxy is an HTTP Handler that takes an incoming request and sends it to another server, proxying the response back to the client.

func NewReverseProxy

func NewReverseProxy(c ReverseProxyConfig) *ReverseProxy

NewReverseProxy initializes a new ReverseProxy with a callback to get backends, a stickyKey for encrypting sticky session cookies, and a flag sticky to enable sticky sessions.

func (*ReverseProxy) ServeConn

func (p *ReverseProxy) ServeConn(ctx context.Context, dconn net.Conn)

ServeConn takes an inbound conn and proxies it to a backend.

func (*ReverseProxy) ServeHTTP

func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

type ReverseProxyConfig

type ReverseProxyConfig struct {
	BackendListFunc   BackendListFunc
	StickyKey         *[32]byte
	Sticky            bool
	DisableKeepAlives bool
	RequestTracker    RequestTracker
	Logger            log15.Logger
}

ReverseProxyConfig is used to initialise a ReverseProxy struct

Jump to

Keyboard shortcuts

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