MCPcopy
hub / github.com/gorilla/websocket / serveWs

Function serveWs

examples/filewatch/main.go:113–129  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

111}
112
113func serveWs(w http.ResponseWriter, r *http.Request) {
114 ws, err := upgrader.Upgrade(w, r, nil)
115 if err != nil {
116 if _, ok := err.(websocket.HandshakeError); !ok {
117 log.Println(err)
118 }
119 return
120 }
121
122 var lastMod time.Time
123 if n, err := strconv.ParseInt(r.FormValue("lastMod"), 16, 64); err == nil {
124 lastMod = time.Unix(0, n)
125 }
126
127 go writer(ws, lastMod)
128 reader(ws)
129}
130
131func serveHome(w http.ResponseWriter, r *http.Request) {
132 if r.URL.Path != "/" {

Callers

nothing calls this directly

Calls 3

writerFunction · 0.85
readerFunction · 0.85
UpgradeMethod · 0.80

Tested by

no test coverage detected