Hello! Thank you for cool framework!
I use code.google.com/p/go.net/websocket package
http.Handle("/socket", websocket.Handler(echoHandler))
How can I handle websocket with gin?
Please, try this:
r := gin.New()
r.GET("/ws", func(c *gin.Context) {
handler := websocket.Handler(EchoServer)
handler.ServeHTTP(c.Writer, c.Req)
})
r.Run(":8080")
@manucorporat, thanks!
@manucorporat , after last update i try:
r := gin.New()
r.GET("/ws", func(c *gin.Context) {
handler := websocket.Handler(EchoServer)
handler.ServeHTTP(c.Writer, c.Req)
})
r.Run(":8080")
Log:
PANIC: interface conversion: *gin.responseWriter is not http.Hijacker: missing method Hijack
I have added the .Hijack() method and an example in my working fork as part of #16, but due to some differences in practice my fork has become incompatible.
I don't want to double the work/headache for myself or the repo maintainer so I won't be making another fork to submit another pull request over a renamed function or two.
If you wanna dig in, look here:
https://github.com/zmarcantel/gin
The relevant parts are in:
response_writer.go
examples/websockets/example_websocket.go
@manucorporat, push to master, so that "go get" would work
Already merged in master ;)
Most helpful comment
Please, try this: