From 36179d2ce233fb0d6a8fbf549891f51f49753965 Mon Sep 17 00:00:00 2001 From: Ola <1386739+olahol@users.noreply.github.com> Date: Fri, 25 Nov 2022 17:42:08 +0100 Subject: [PATCH] Update filewatch example --- examples/filewatch/main.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/filewatch/main.go b/examples/filewatch/main.go index 0a790d3..ba97134 100644 --- a/examples/filewatch/main.go +++ b/examples/filewatch/main.go @@ -1,26 +1,25 @@ package main import ( - "github.com/gin-gonic/gin" - "github.com/fsnotify/fsnotify" - "github.com/olahol/melody" "io/ioutil" "net/http" + + "github.com/fsnotify/fsnotify" + "github.com/olahol/melody" ) func main() { file := "file.txt" - r := gin.Default() m := melody.New() w, _ := fsnotify.NewWatcher() - r.GET("/", func(c *gin.Context) { - http.ServeFile(c.Writer, c.Request, "index.html") + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "index.html") }) - r.GET("/ws", func(c *gin.Context) { - m.HandleRequest(c.Writer, c.Request) + http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) { + m.HandleRequest(w, r) }) m.HandleConnect(func(s *melody.Session) { @@ -40,5 +39,5 @@ func main() { w.Add(file) - r.Run(":5000") + http.ListenAndServe(":5000", nil) }