Documentation ¶
Overview ¶
Package wsproxy implements a websocket proxy for grpc-gateway backed services
Index ¶
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 WithMethodParamOverride ¶
WithMethodParamOverride allows specification of the special http parameter that is used in the proxied streaming request.
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.