forward

package
v0.0.0-...-d11463e Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

package forwarder implements http handler that forwards requests to remote server and serves back the response websocket proxying support based on https://github.com/yhat/wsutil

Index

Constants

View Source
const (
	StateConnected = iota
	StateDisconnected
)
View Source
const (
	XForwardedProto    = "X-Forwarded-Proto"
	XForwardedFor      = "X-Forwarded-For"
	XForwardedHost     = "X-Forwarded-Host"
	XForwardedServer   = "X-Forwarded-Server"
	Connection         = "Connection"
	KeepAlive          = "Keep-Alive"
	ProxyAuthenticate  = "Proxy-Authenticate"
	ProxyAuthorization = "Proxy-Authorization"
	Te                 = "Te" // canonicalized version of "TE"
	Trailers           = "Trailers"
	TransferEncoding   = "Transfer-Encoding"
	Upgrade            = "Upgrade"
	ContentLength      = "Content-Length"
)

Variables

Hop-by-hop headers. These are removed when sent to the backend. http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html Copied from reverseproxy.go, too bad

Functions

func ErrorHandler

func ErrorHandler(h utils.ErrorHandler) optSetter

ErrorHandler is a functional argument that sets error handler of the server

func IsWebsocketRequest

func IsWebsocketRequest(req *http.Request) bool

isWebsocketRequest determines if the specified HTTP request is a websocket handshake request

func PassHostHeader

func PassHostHeader(b bool) optSetter

PassHostHeader specifies if a client's Host header field should be delegated

func Rewriter

func Rewriter(r ReqRewriter) optSetter

Rewriter defines a request rewriter for the HTTP forwarder

func RoundTripper

func RoundTripper(r http.RoundTripper) optSetter

RoundTripper sets a new http.RoundTripper Forwarder will use http.DefaultTransport as a default round tripper

func StateListener

func StateListener(stateListener UrlForwardingStateListener) optSetter

func Stream

func Stream(stream bool) optSetter

Logger specifies the logger to use. Forwarder will default to oxyutils.NullLogger if no logger has been specified

func StreamingFlushInterval

func StreamingFlushInterval(flushInterval time.Duration) optSetter

func WebsocketTLSClientConfig

func WebsocketTLSClientConfig(tcc *tls.Config) optSetter

PassHostHeader specifies if a client's Host header field should be delegated

Types

type Forwarder

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

Forwarder wraps two traffic forwarding implementations: HTTP and websockets. It decides based on the specified request which implementation to use

func New

func New(setters ...optSetter) (*Forwarder, error)

New creates an instance of Forwarder based on the provided list of configuration options

func (*Forwarder) ServeHTTP

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

ServeHTTP decides which forwarder to use based on the specified request and delegates to the proper implementation

type HeaderRewriter

type HeaderRewriter struct {
	TrustForwardHeader bool
	Hostname           string
}

Rewriter is responsible for removing hop-by-hop headers and setting forwarding headers

func (*HeaderRewriter) Rewrite

func (rw *HeaderRewriter) Rewrite(req *http.Request)

type ReqRewriter

type ReqRewriter interface {
	Rewrite(r *http.Request)
}

ReqRewriter can alter request headers and body

type UrlForwardingStateListener

type UrlForwardingStateListener func(*url.URL, int)

Jump to

Keyboard shortcuts

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