proxy

package
v1.8.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package proxy provides transport and upgrade support for proxies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialURL

func DialURL(url *url.URL, transport http.RoundTripper) (net.Conn, error)

Types

type ErrorResponder

type ErrorResponder interface {
	Error(err error)
}

ErrorResponder abstracts error reporting to the proxy handler to remove the need to hardcode a particular error format.

type Transport

type Transport struct {
	Scheme      string
	Host        string
	PathPrepend string

	http.RoundTripper
}

Transport is a transport for text/html content that replaces URLs in html content with the prefix of the proxy server

func (*Transport) RoundTrip

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

RoundTrip implements the http.RoundTripper interface

func (*Transport) WrappedRoundTripper

func (rt *Transport) WrappedRoundTripper() http.RoundTripper

type UpgradeAwareHandler

type UpgradeAwareHandler struct {
	UpgradeRequired bool
	Location        *url.URL
	// Transport provides an optional round tripper to use to proxy. If nil, the default proxy transport is used
	Transport http.RoundTripper
	// WrapTransport indicates whether the provided Transport should be wrapped with default proxy transport behavior (URL rewriting, X-Forwarded-* header setting)
	WrapTransport bool
	// InterceptRedirects determines whether the proxy should sniff backend responses for redirects,
	// following them as necessary.
	InterceptRedirects bool
	FlushInterval      time.Duration
	MaxBytesPerSec     int64
	Responder          ErrorResponder
}

UpgradeAwareHandler is a handler for proxy requests that may require an upgrade

func NewUpgradeAwareHandler

func NewUpgradeAwareHandler(location *url.URL, transport http.RoundTripper, wrapTransport, upgradeRequired bool, responder ErrorResponder) *UpgradeAwareHandler

NewUpgradeAwareHandler creates a new proxy handler with a default flush interval. Responder is required for returning errors to the caller.

func (*UpgradeAwareHandler) Dial

func (h *UpgradeAwareHandler) Dial(req *http.Request) (net.Conn, error)

Dial dials the backend at req.URL and writes req to it.

func (*UpgradeAwareHandler) ServeHTTP

func (h *UpgradeAwareHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP handles the proxy request

Jump to

Keyboard shortcuts

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