ws upgrade fail error message.

This commit is contained in:
Miroslav Šedivý 2020-10-28 22:28:10 +01:00
parent 4b39607af0
commit e1ef49c46a

View File

@ -33,7 +33,9 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler) *Server {
router.Use(customMiddleware.Logger) // Log API request calls using custom logger function router.Use(customMiddleware.Logger) // Log API request calls using custom logger function
router.Get("/ws", func(w http.ResponseWriter, r *http.Request) { router.Get("/ws", func(w http.ResponseWriter, r *http.Request) {
webSocketHandler.Upgrade(w, r) if webSocketHandler.Upgrade(w, r) != nil {
w.Write([]byte("unable to upgrade your connection to a websocket"))
}
}) })
fs := http.FileServer(http.Dir(conf.Static)) fs := http.FileServer(http.Dir(conf.Static))