Files
2024-04-05 14:07:52 +03:00

28 lines
424 B
Go

package main
import (
"net/http"
"git.company.lan/gopkg/gin"
"git.company.lan/gopkg/melody"
)
func main() {
r := gin.Default()
m := melody.New()
r.GET("/", func(c *gin.Context) {
http.ServeFile(c.Writer, c.Request, "index.html")
})
r.GET("/ws", func(c *gin.Context) {
m.HandleRequest(c.Writer, c.Request)
})
m.HandleMessage(func(s *melody.Session, msg []byte) {
m.Broadcast(msg)
})
r.Run(":5000")
}