-
-
Notifications
You must be signed in to change notification settings - Fork 564
/
Copy pathwebsocket.go
27 lines (22 loc) Β· 890 Bytes
/
websocket.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package http
import (
"context"
"net/http"
"github.com/gorilla/websocket"
)
type (
// Upgrader is an HTTP connection that is able to upgrade to websocket.
Upgrader interface {
// Upgrade upgrades the HTTP connection to the websocket protocol.
Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*websocket.Conn, error)
}
// Dialer creates a websocket connection to a given URL.
Dialer interface {
// DialContext creates a client connection to the websocket server.
DialContext(ctx context.Context, url string, h http.Header) (*websocket.Conn, *http.Response, error)
}
// ConnConfigureFunc is used to configure a websocket connection with
// custom handlers. The cancel function cancels the request context when
// invoked in the configure function.
ConnConfigureFunc func(conn *websocket.Conn, cancel context.CancelFunc) *websocket.Conn
)