reverseproxy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package `reverseproxy` forwards the requests to backends. It gets additional request headers from `header_injectors`, and adds to the forwarding request to downstream.

Index

Constants

View Source
const (
	ProbeStatusCode = http.StatusOK
	ProbeResponse   = "OK"
)

Variables

This section is empty.

Functions

func IsKubernetesProbeRequest added in v0.3.0

func IsKubernetesProbeRequest(r *http.Request) bool

Types

type HTTPHandler

type HTTPHandler struct {

	// required, the URL that requests will be forwarding to
	To *url.URL

	// optional, preserve the host in outbound requests
	PreserveHost bool

	// optional, but in fact required, injecting fingerprint headers to outbound requests
	HeaderInjectors []HeaderInjector

	// optional, if IsProbeRequest returns true, handler will respond with
	// a HTTP 200 OK instead of forwarding requests, useful for kubernetes
	// liveness/readiness probes. defaults to nil, which disables this behavior
	IsProbeRequest func(*http.Request) bool
	// contains filtered or unexported fields
}

func NewHTTPHandler

func NewHTTPHandler(to *url.URL, reverseProxy *httputil.ReverseProxy, headerInjectors []HeaderInjector) *HTTPHandler

NewHTTPHandler creates an HTTP handler, changes `reverseProxy.Rewrite` to support request header injection, then assigns `reverseProxy` to the handler which proxies requests to backend

func (*HTTPHandler) ServeHTTP

func (f *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type HeaderInjector

type HeaderInjector interface {
	GetHeaderName() string

	GetHeaderValue(req *http.Request) (string, error)
}

Jump to

Keyboard shortcuts

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