Created
October 19, 2022 15:07
-
-
Save leoantony72/c9d3fc6b525e5de3a889992d10f34776 to your computer and use it in GitHub Desktop.
Go websocket config file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var upgrader = websocket.Upgrader{ | |
ReadBufferSize: 1024, | |
WriteBufferSize: 1024, | |
} | |
func Wshandler(w http.ResponseWriter, r *http.Request, c *gin.Context) { | |
upgrader.CheckOrigin = func(r *http.Request) bool { return true } | |
conn, err := upgrader.Upgrade(w, r, nil) | |
if err != nil { | |
fmt.Printf("Failed to set websocket upgrade: %+v", err) | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment