proxy

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessAsyncOperationHeaders

func ProcessAsyncOperationHeaders(resp *http.Response) error

ProcessAsyncOperationHeaders is a ResponderFunc that processes the Azure-AsyncOperation header and Location header to match the UCP hostname and scheme based on the Referrer header.

Users of this director should ensure the referrer header is set on the request before proxying. The referrer header should contain the original UCP request URL.

The values of the Azure-AsyncOperation and Location headers are rewritten to point to the UCP endpoint. If the result header values omit the plane-prefix (eg: /subscriptions/...), then the plane-prefix is prepended to the header value. The query string returned by the downstream are preserved.

Types

type DirectorFunc

type DirectorFunc = func(r *http.Request)

DirectorFunc is a function that modifies the request before it is sent to the downstream server.

type ErrorHandlerFunc

type ErrorHandlerFunc = func(w http.ResponseWriter, r *http.Request, err error)

ErrorHandlerFunc is a function that handles errors that occur during the request.

type ResponderFunc

type ResponderFunc = func(r *http.Response) error

ResponderFunc is a function that modifies the response before it is sent to the client.

type ReverseProxy

type ReverseProxy interface {
	http.Handler
}

ReverseProxy defines the interface for a reverse proxy.

func NewARMProxy

func NewARMProxy(options ReverseProxyOptions, downstream *url.URL, configure func(builder *ReverseProxyBuilder)) ReverseProxy

NewARMProxy creates a ReverseProxy with custom directors, transport and responders to process requests and responses.

type ReverseProxyBuilder

type ReverseProxyBuilder struct {
	// Downstream is the URL of the downstream server. This is the URL of the destination.
	//
	// The downstream URL will replace the request URL's scheme, host, and port. If the downstream
	// URL contains a path, it will be pre-pended to the request URL's path.
	Downstream *url.URL

	// EnableLogging enables a set of logging middleware for the proxy.
	EnableLogging bool

	// Directors is the set of director functions to be applied to the reverse proxy.
	// Directors are applied in order and modify the request before it is sent to the downstream server.
	Directors []DirectorFunc

	// Responders is the set of responder functions to be applied to the reverse proxy.
	// Responses are applied in REVERSE order and modify the response before it is sent to the client.
	Responders []ResponderFunc

	// ErrorHandler is the error handler function to be applied to the reverse proxy.
	// The error handler is called when an Golang error. This is NOT called for HTTP errors such
	// as 404 or 500.
	ErrorHandler ErrorHandlerFunc

	// Transport is the transport set on the created httputil.ReverseProxy.
	Transport http.RoundTripper
}

func (*ReverseProxyBuilder) Build

func (builder *ReverseProxyBuilder) Build() ReverseProxy

Build configures a ReverseProxy with the given parameters and returns a http.HandlerFunc.

type ReverseProxyOptions

type ReverseProxyOptions struct {
	// RoundTripper is the round tripper used by the reverse proxy to send requests.
	RoundTripper http.RoundTripper
}

ReverseProxyOptions defines the options for creating a reverse proxy.

Jump to

Keyboard shortcuts

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