http

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const NoHostOverride = ""

NoHostOverride signifies that no host overriding should be done and that the host should be inferred from the target of the reverse-proxy.

Variables

This section is empty.

Functions

func NewHeaderPruningReverseProxy added in v0.30.2

func NewHeaderPruningReverseProxy(target, hostOverride string, headersToRemove []string) *httputil.ReverseProxy

NewHeaderPruningReverseProxy returns a httputil.ReverseProxy that proxies requests to the given targetHost after removing the headersToRemove. If hostOverride is not an empty string, the outgoing request's Host header will be replaced with that explicit value and the passthrough loadbalancing header will be set to enable pod-addressability.

Types

type RequestLogHandler added in v0.6.0

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

RequestLogHandler implements an http.Handler that writes request logs and calls the next handler.

func NewRequestLogHandler added in v0.6.0

func NewRequestLogHandler(h http.Handler, w io.Writer, templateStr string,
	inputGetter RequestLogTemplateInputGetter, enableProbeRequestLog bool) (*RequestLogHandler, error)

NewRequestLogHandler creates an http.Handler that logs request logs to an io.Writer.

func (*RequestLogHandler) ServeHTTP added in v0.6.0

func (h *RequestLogHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*RequestLogHandler) SetTemplate added in v0.6.0

func (h *RequestLogHandler) SetTemplate(templateStr string) error

SetTemplate sets the template to use for formatting request logs. Setting the template to an empty string turns off writing request logs.

type RequestLogResponse added in v0.6.0

type RequestLogResponse struct {
	Code    int
	Size    int
	Latency float64
}

RequestLogResponse provided response related information for the template execution.

type RequestLogRevision added in v0.6.0

type RequestLogRevision struct {
	Name          string
	Namespace     string
	Service       string
	Configuration string
	PodName       string
	PodIP         string
}

RequestLogRevision provides revision related static information for the template execution.

type RequestLogTemplateInput added in v0.6.0

type RequestLogTemplateInput struct {
	Request  *http.Request
	Response *RequestLogResponse
	Revision *RequestLogRevision
}

RequestLogTemplateInput is the wrapper struct that provides all necessary information for the template execution.

type RequestLogTemplateInputGetter added in v0.6.0

type RequestLogTemplateInputGetter func(req *http.Request, resp *RequestLogResponse) *RequestLogTemplateInput

RequestLogTemplateInputGetter defines a function returning the input to pass to a request log writer.

func RequestLogTemplateInputGetterFromRevision added in v0.6.0

func RequestLogTemplateInputGetterFromRevision(rev *RequestLogRevision) RequestLogTemplateInputGetter

RequestLogTemplateInputGetterFromRevision returns a func that forms a template input using a static revision information.

type ResponseRecorder added in v0.5.0

type ResponseRecorder struct {
	ResponseCode int
	ResponseSize int
	// contains filtered or unexported fields
}

ResponseRecorder is an implementation of http.ResponseWriter and http.Flusher that captures the response code and size.

func NewResponseRecorder added in v0.5.0

func NewResponseRecorder(w http.ResponseWriter, responseCode int) *ResponseRecorder

NewResponseRecorder creates an http.ResponseWriter that captures the response code and size.

func (*ResponseRecorder) Flush added in v0.5.0

func (rr *ResponseRecorder) Flush()

Flush flushes the buffer to the client.

func (*ResponseRecorder) Header added in v0.5.0

func (rr *ResponseRecorder) Header() http.Header

Header returns the header map that will be sent by WriteHeader.

func (*ResponseRecorder) Hijack added in v0.5.0

func (rr *ResponseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack calls Hijack() on the wrapped http.ResponseWriter if it implements http.Hijacker interface, which is required for net/http/httputil/reverseproxy to handle connection upgrade/switching protocol. Otherwise returns an error.

func (*ResponseRecorder) Write added in v0.5.0

func (rr *ResponseRecorder) Write(p []byte) (int, error)

Write writes the data to the connection as part of an HTTP reply.

func (*ResponseRecorder) WriteHeader added in v0.5.0

func (rr *ResponseRecorder) WriteHeader(code int)

WriteHeader sends an HTTP response header with the provided status code.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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