Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Specifies either the allowed origins. // The "*" wildcard, allow any origin. AllowedOrigins []string // HandshakeTimeout specifies the duration for the handshake to complete. HandshakeTimeout time.Duration // ReadBufferSize and WriteBufferSize specify I/O buffer sizes in bytes. If a buffer // size is zero, then buffers allocated by the HTTP server are used. The // I/O buffer sizes do not limit the size of the messages that can be sent // or received. ReadBufferSize, WriteBufferSize int // Subprotocols specifies the server's supported protocols in order of // preference. If this field is not nil, then the Upgrade method negotiates a // subprotocol by selecting the first match in this list with a protocol // requested by the client. If there's no match, then no protocol is // negotiated (the Sec-Websocket-Protocol header is not included in the // handshake response). Subprotocols []string // EnableCompression specify if the server should attempt to negotiate per // message compression (RFC 7692). Setting this value to true does not // guarantee that compression will be supported. Currently only "no context // takeover" modes are supported. EnableCompression bool // Error specifies the function for generating HTTP error responses. If Error // is nil, then http.Error is used to generate the HTTP response. Error atreugo.ErrorView // Logger is used for logging formatted messages. Logger *logger.Logger }
Config configuration for upgrading an HTTP connection to a WebSocket connection.
type Conn ¶
Conn represents a WebSocket connection.
func (*Conn) SetUserValue ¶
SetUserValue stores the given value (arbitrary object) under the given key.
The value stored may be obtained by UserValue*.
func (*Conn) SetUserValueBytes ¶
SetUserValueBytes stores the given value (arbitrary object) under the given key.
The value stored may be obtained by UserValue*.
func (*Conn) UserValueBytes ¶
UserValueBytes returns the value stored via SetUserValue* under the given key.
type Upgrader ¶
type Upgrader struct {
// contains filtered or unexported fields
}
Upgrader tool to convert the websocket view to an atreugo view.
func (*Upgrader) Upgrade ¶
Upgrade converts the websocket view to an atreugo view. The returned view upgrades the HTTP server connection to the WebSocket protocol.
All ctx.UserValues are stored in the websocket connection, being availables through ws.UserValue()
The responseHeader is included in the response to the client's upgrade request. Use the responseHeader to specify cookies (Set-Cookie) and the application negotiated subprotocol (Sec-WebSocket-Protocol).
If the upgrade fails, the view replies to the client with an HTTP error response.