import "github.com/koding/websocketproxy"
Package websocketproxy is a reverse proxy for WebSocket connections.
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
)ProxyHandler returns a new http.Handler interface that reverse proxies the request to the given target.
type WebsocketProxy struct {
// 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.
func NewProxy(target *url.URL) *WebsocketProxy
NewProxy returns a new Websocket reverse proxy that rewrites the URL's to the scheme, host and base path provider in target.
func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP implements the http.Handler that proxies WebSocket connections.
Package websocketproxy imports 7 packages (graph) and is imported by 9 packages. Updated 2015-07-07. Refresh now. Tools for package owners.