var MethodOverrideParam … var TokenCookieName … type RequestMutatorFunc … type Proxy … type Logger … func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { … } type Option … // WithMaxRespBodyBufferSize allows specification of a custom size for the // buffer used while reading the response body. By default, the bufio.Scanner // used to read the response body sets the maximum token size to MaxScanTokenSize. func WithMaxRespBodyBufferSize(nBytes int) Option { … } // WithMethodParamOverride allows specification of the special http parameter that is used in the proxied streaming request. func WithMethodParamOverride(param string) Option { … } // WithTokenCookieName allows specification of the cookie that is supplied as an upstream 'Authorization: Bearer' http header. func WithTokenCookieName(param string) Option { … } // WithRequestMutator allows a custom RequestMutatorFunc to be supplied. func WithRequestMutator(fn RequestMutatorFunc) Option { … } // WithForwardedHeaders allows controlling which headers are forwarded. func WithForwardedHeaders(fn func(header string) bool) Option { … } // WithLogger allows a custom FieldLogger to be supplied func WithLogger(logger Logger) Option { … } // WithPingControl allows specification of ping pong control. The interval // parameter specifies the pingInterval between pings. The allowed wait time // for a pong response is (pingInterval * 10) / 9. func WithPingControl(interval time.Duration) Option { … } var defaultHeadersToForward … func defaultHeaderForwarder(header string) bool { … } // WebsocketProxy attempts to expose the underlying handler as a bidi websocket stream with newline-delimited // JSON as the content encoding. // // The HTTP Authorization header is either populated from the Sec-Websocket-Protocol field or by a cookie. // The cookie name is specified by the TokenCookieName value. // // example: // Sec-Websocket-Protocol: Bearer, foobar // is converted to: // Authorization: Bearer foobar // // Method can be overwritten with the MethodOverrideParam get parameter in the requested URL func WebsocketProxy(h http.Handler, opts ...Option) http.Handler { … } var upgrader … func isClosedConnError(err error) bool { … } func (p *Proxy) proxy(w http.ResponseWriter, r *http.Request) { … } type inMemoryResponseWriter … func newInMemoryResponseWriter(w io.Writer) *inMemoryResponseWriter { … } // IE and Edge do not delimit Sec-WebSocket-Protocol strings with spaces func transformSubProtocolHeader(header string) string { … } func (w *inMemoryResponseWriter) Write(b []byte) (int, error) { … } func (w *inMemoryResponseWriter) Header() http.Header { … } func (w *inMemoryResponseWriter) WriteHeader(code int) { … } func (w *inMemoryResponseWriter) CloseNotify() <-chan bool { … } func (w *inMemoryResponseWriter) Flush() { … }