We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to gin + gorilla/websocket support WebSocket
The text was updated successfully, but these errors were encountered:
gorilla/websocket has provided sample codes like this:
gorilla/websocket
var upgrader = websocket.Upgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, } func handler(w http.ResponseWriter, r *http.Request) { conn, err := upgrader.Upgrade(w, r, nil) if err != nil { log.Println(err) return } // ... Use conn to send and receive messages. }
So, in my opinion, you just wonder how to get http.Request and http.ResponseWriter from gin.Context? That's simple:
http.Request
http.ResponseWriter
gin.Context
func handler(c *gin.Context) { conn, err := upgrader.Upgrade(c.Writer, c.Request, nil) if err != nil { log.Println(err) return } // ... Use conn to send and receive messages. }
now all others are same to official document.
Sorry, something went wrong.
No branches or pull requests
How to gin + gorilla/websocket support WebSocket
The text was updated successfully, but these errors were encountered: