Documentation ¶
Overview ¶
Package wsproxy implements a websocket proxy for grpc-gateway backed services
Index ¶
- Variables
- func WebsocketProxy(h http.Handler, opts ...Option) http.Handler
- type Logger
- type Option
- func WithForwardedHeaders(fn func(header string) bool) Option
- func WithLogger(logger Logger) Option
- func WithMaxRespBodyBufferSize(nBytes int) Option
- func WithMethodParamOverride(param string) Option
- func WithPingControl(interval time.Duration) Option
- func WithRequestMutator(fn RequestMutatorFunc) Option
- func WithTokenCookieName(param string) Option
- type Proxy
- type RequestMutatorFunc
Constants ¶
This section is empty.
Variables ¶
var MethodOverrideParam = "method"
MethodOverrideParam defines the special URL parameter that is translated into the subsequent proxied streaming http request's method.
Deprecated: it is preferable to use the Options parameters to WebSocketProxy to supply parameters.
var TokenCookieName = "token"
TokenCookieName defines the cookie name that is translated to an 'Authorization: Bearer' header in the streaming http request's headers.
Deprecated: it is preferable to use the Options parameters to WebSocketProxy to supply parameters.
Functions ¶
func WebsocketProxy ¶
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
Types ¶
type Logger ¶
type Logger interface { Warnln(...interface{}) Debugln(...interface{}) }
Logger collects log messages.
type Option ¶
type Option func(*Proxy)
Option allows customization of the proxy.
func WithForwardedHeaders ¶
WithForwardedHeaders allows controlling which headers are forwarded.
func WithLogger ¶
WithLogger allows a custom FieldLogger to be supplied
func WithMaxRespBodyBufferSize ¶
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 WithMethodParamOverride ¶
WithMethodParamOverride allows specification of the special http parameter that is used in the proxied streaming request.
func WithPingControl ¶
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 WithRequestMutator ¶
func WithRequestMutator(fn RequestMutatorFunc) Option
WithRequestMutator allows a custom RequestMutatorFunc to be supplied.
func WithTokenCookieName ¶
WithTokenCookieName allows specification of the cookie that is supplied as an upstream 'Authorization: Bearer' http header.