I look at your code. And find it wonderful. But I think it would be better to return not only error from upgrader.Upgrade(ctx) but also connnection. It can helps create every time new connections and work with messages by topic. Also it could be compatible with original idea of "github.com/gorilla/websocket". How do you think?
func myChatHandler(ctx *fasthttp.RequestCtx) { err := upgrader.Upgrade(ctx)// returns only error, executes the handler you defined on the websocket.New before (the 'chat' function) }
I look at your code. And find it wonderful. But I think it would be better to return not only error from upgrader.Upgrade(ctx) but also connnection. It can helps create every time new connections and work with messages by topic. Also it could be compatible with original idea of "github.com/gorilla/websocket". How do you think?
func myChatHandler(ctx *fasthttp.RequestCtx) { err := upgrader.Upgrade(ctx)// returns only error, executes the handler you defined on the websocket.New before (the 'chat' function) }