Documentation ¶
Overview ¶
Package ws implements a simple WebSocket transport for mangos. This transport is considered EXPERIMENTAL.
Index ¶
Constants ¶
View Source
const ( // OptionWebSocketMux is a retrieve-only property used to obtain // the *http.ServeMux instance associated with the server. This // can be used to subsequently register additional handlers for // different URIs. This option is only valid on a Listener. // Generally you use this option when you want to use the standard // mangos Listen() method to start up the server. OptionWebSocketMux = "WEBSOCKET-MUX" // OptionWebSocketHandler is used to obtain the underlying // http.Handler (websocket.Server) object, so you can use this // on your own http.Server instances. It is a gross error to use // the value returned by this method on an http server if the // server is also started with mangos Listen(). This means that you // will use at most either this option, or OptionWebSocketMux, but // never both. This option is only valid on a listener. OptionWebSocketHandler = "WEBSOCKET-HANDLER" // OptionWebSocketCheckOrigin controls the check of the origin of the // underlying Listener (websocket.Upgrader). // Excerpt from https://godoc.org/github.com/gorilla/websocket: // Web browsers allow Javascript applications to open a WebSocket // connection to any host. It's up to the server to enforce an origin // policy using the Origin request header sent by the browser. The // Upgrader calls the function specified in the CheckOrigin field to // check the origin. If the CheckOrigin function returns false, then // the Upgrade method fails the WebSocket handshake with HTTP status // 403. If the CheckOrigin field is nil, then the Upgrader uses a safe // default: fail the handshake if the Origin request header is present // and not equal to the Host request header. An application can allow // connections from any origin by specifying a function that always // returns true: // // var upgrader = websocket.Upgrader{ // CheckOrigin: func(r *http.Request) bool { return true }, // } // // The deprecated Upgrade function does not enforce an origin policy. // It's the application's responsibility to check the Origin header // before calling Upgrade. OptionWebSocketCheckOrigin = "WEBSOCKET-CHECKORIGIN" )
Some special options
Variables ¶
This section is empty.
Functions ¶
func NewTransport ¶
func NewTransport() mangos.Transport
NewTransport allocates a new ws:// transport.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.