Commit 59e7057f authored by rui.zheng's avatar rui.zheng

fix websocket crash

parent 3835ab43
...@@ -129,15 +129,18 @@ func (s *ws) handle(w http.ResponseWriter, r *http.Request) { ...@@ -129,15 +129,18 @@ func (s *ws) handle(w http.ResponseWriter, r *http.Request) {
} }
func (s *ws) ListenAndServe() error { func (s *ws) ListenAndServe() error {
http.HandleFunc("/ws", s.handle) sm := http.NewServeMux()
return http.ListenAndServe(s.arg.Addr, nil) sm.HandleFunc("/ws", s.handle)
return http.ListenAndServe(s.arg.Addr, sm)
} }
func (s *ws) listenAndServeTLS() error { func (s *ws) listenAndServeTLS() error {
http.HandleFunc("/ws", s.handle) sm := http.NewServeMux()
sm.HandleFunc("/ws", s.handle)
server := &http.Server{ server := &http.Server{
Addr: s.arg.Addr, Addr: s.arg.Addr,
TLSConfig: &tls.Config{Certificates: []tls.Certificate{s.arg.Cert}}, TLSConfig: &tls.Config{Certificates: []tls.Certificate{s.arg.Cert}},
Handler: sm,
} }
return server.ListenAndServeTLS("", "") return server.ListenAndServeTLS("", "")
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment