Documentation
¶
Overview ¶
Package websocketproxy is a reverse proxy for WebSocket connections. Originally from https://github.com/koding/websocketproxy Changes made: added Ping handler to connPub, which sends ping to connBackend
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// DefaultUpgrader specifies the parameters for upgrading an HTTP
// connection to a WebSocket connection.
DefaultUpgrader = &websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
// DefaultDialer is a dialer with all fields set to the default zero values.
DefaultDialer = websocket.DefaultDialer
)
Functions ¶
func ProxyHandler ¶
func ProxyHandler(target *url.URL) http.Handler
ProxyHandler returns a new http.Handler interface that reverse proxies the request to the given target.
Types ¶
type WebsocketProxy ¶
type WebsocketProxy struct {
// Director, if non-nil, is a function that may copy additional request
// headers from the incoming WebSocket connection into the output headers
// which will be forwarded to another server.
Director func(incoming *http.Request, out http.Header)
// Backend returns the backend URL which the proxy uses to reverse proxy
// the incoming WebSocket connection. Request is the initial incoming and
// unmodified request.
Backend func(*http.Request) *url.URL
// Upgrader specifies the parameters for upgrading a incoming HTTP
// connection to a WebSocket connection. If nil, DefaultUpgrader is used.
Upgrader *websocket.Upgrader
// Dialer contains options for connecting to the backend WebSocket server.
// If nil, DefaultDialer is used.
Dialer *websocket.Dialer
}
WebsocketProxy is an HTTP Handler that takes an incoming WebSocket connection and proxies it to another server.
Click to show internal directories.
Click to hide internal directories.