package main import ( "fmt" "net/http" "strings" "github.com/coder/websocket" ) func isWS(r *http.Request) bool { return r.URL.Path == "/ws" || strings.HasPrefix(r.URL.Path, "/ws/") } func (s *S) serveWS(httpw http.ResponseWriter, httpr *http.Request) error { ctx := httpr.Context() c, err := websocket.Accept(httpw, httpr, nil) if err != nil { return err } defer c.CloseNow() if err := c.Write(ctx, 1, []byte("hello world")); err != nil { return err } return fmt.Errorf("not impl") }