Create Go module

This commit is contained in:
Ola
2022-09-13 15:06:52 +02:00
parent e21886f3a7
commit 5dfe76a8fb
12 changed files with 188 additions and 94 deletions
+6 -7
View File
@@ -1,10 +1,9 @@
package main
import (
"github.com/labstack/echo"
"github.com/labstack/echo/engine/standard"
"github.com/labstack/echo/middleware"
"gopkg.in/olahol/melody.v1"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/olahol/melody"
"net/http"
)
@@ -16,12 +15,12 @@ func main() {
e.Use(middleware.Recover())
e.GET("/", func(c echo.Context) error {
http.ServeFile(c.Response().(*standard.Response).ResponseWriter, c.Request().(*standard.Request).Request, "index.html")
http.ServeFile(c.Response().Writer, c.Request(), "index.html")
return nil
})
e.GET("/ws", func(c echo.Context) error {
m.HandleRequest(c.Response().(*standard.Response).ResponseWriter, c.Request().(*standard.Request).Request)
m.HandleRequest(c.Response().Writer, c.Request())
return nil
})
@@ -29,5 +28,5 @@ func main() {
m.Broadcast(msg)
})
e.Run(standard.New(":5000"))
e.Logger.Fatal(e.Start(":5000"))
}