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
- Variables
- func ErrorHandler(h utils.ErrorHandler) optSetter
- func IsWebsocketRequest(req *http.Request) bool
- func Logger(l log.FieldLogger) optSetter
- func PassHostHeader(b bool) optSetter
- func ResponseModifier(responseModifier func(*http.Response) error) optSetter
- func Rewriter(r ReqRewriter) optSetter
- func RoundTripper(r http.RoundTripper) optSetter
- func StateListener(stateListener UrlForwardingStateListener) optSetter
- func Stream(stream bool) optSetter
- func StreamingFlushInterval(flushInterval time.Duration) optSetter
- func WebsocketTLSClientConfig(tcc *tls.Config) optSetter
- type ErrorHandlingRoundTripper
- type Forwarder
- type HeaderRewriter
- type OxyLogger
- type ReqRewriter
- type UrlForwardingStateListener
Constants ¶
const ( StateConnected = iota StateDisconnected )
const ( XForwardedProto = "X-Forwarded-Proto" XForwardedFor = "X-Forwarded-For" XForwardedHost = "X-Forwarded-Host" XForwardedPort = "X-Forwarded-Port" XForwardedServer = "X-Forwarded-Server" XRealIp = "X-Real-Ip" 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" SecWebsocketKey = "Sec-Websocket-Key" SecWebsocketVersion = "Sec-Websocket-Version" SecWebsocketExtensions = "Sec-Websocket-Extensions" SecWebsocketAccept = "Sec-Websocket-Accept" )
Variables ¶
var HopHeaders = []string{ Connection, KeepAlive, ProxyAuthenticate, ProxyAuthorization, Te, Trailers, TransferEncoding, Upgrade, }
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
var WebsocketDialHeaders = []string{ Upgrade, Connection, SecWebsocketKey, SecWebsocketVersion, SecWebsocketExtensions, SecWebsocketAccept, }
var WebsocketUpgradeHeaders = []string{ Upgrade, Connection, SecWebsocketAccept, SecWebsocketExtensions, }
var XHeaders = []string{ XForwardedProto, XForwardedFor, XForwardedHost, XForwardedPort, XForwardedServer, XRealIp, }
Functions ¶
func ErrorHandler ¶
func ErrorHandler(h utils.ErrorHandler) optSetter
ErrorHandler is a functional argument that sets error handler of the server
func IsWebsocketRequest ¶
isWebsocketRequest determines if the specified HTTP request is a websocket handshake request
func Logger ¶
func Logger(l log.FieldLogger) optSetter
Logger defines the logger the forwarder will use.
It defaults to logrus.StandardLogger(), the global logger used by logrus.
func PassHostHeader ¶
func PassHostHeader(b bool) optSetter
PassHostHeader specifies if a client's Host header field should be delegated
func ResponseModifier ¶
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
Stream specifies if HTTP responses should be streamed.
func StreamingFlushInterval ¶
func WebsocketTLSClientConfig ¶
PassHostHeader specifies if a client's Host header field should be delegated
Types ¶
type ErrorHandlingRoundTripper ¶
type ErrorHandlingRoundTripper struct { http.RoundTripper // contains filtered or unexported fields }
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
type HeaderRewriter ¶
Rewriter is responsible for removing hop-by-hop headers and setting forwarding headers
func (*HeaderRewriter) Rewrite ¶
func (rw *HeaderRewriter) Rewrite(req *http.Request)
type OxyLogger ¶
type OxyLogger interface { log.FieldLogger GetLevel() log.Level }
Oxy Logger interface of the internal
type ReqRewriter ¶
ReqRewriter can alter request headers and body