game Of Life
This commit is contained in:
13
src/main.go
13
src/main.go
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
"github.com/labstack/gommon/log"
|
||||
"knet.sk/src/boxes"
|
||||
"knet.sk/src/draw"
|
||||
)
|
||||
|
||||
@@ -25,10 +26,10 @@ func NewTemplates() *Templates {
|
||||
}
|
||||
|
||||
type Page struct {
|
||||
Boxes map[int]bool
|
||||
Boxes []boxes.Box
|
||||
}
|
||||
|
||||
func newPage(boxes map[int]bool) Page {
|
||||
func newPage(boxes []boxes.Box) Page {
|
||||
return Page{
|
||||
Boxes: boxes,
|
||||
}
|
||||
@@ -50,20 +51,16 @@ func main() {
|
||||
e.Static("/js", "js")
|
||||
|
||||
e.GET("/", func(c echo.Context) error {
|
||||
return c.Render(200, "index", newPage(getBoxes()))
|
||||
return c.Render(200, "index", newPage(boxes.GetBoxes()))
|
||||
})
|
||||
e.GET("/boxes/ws", boxes.InitWs)
|
||||
|
||||
e.GET("/ws", initWs)
|
||||
|
||||
//favicon
|
||||
e.File("/favicon.ico", "images/favicon.ico")
|
||||
|
||||
e.GET("/draw", draw.Page)
|
||||
e.GET("/draw/ws", draw.InitWs)
|
||||
|
||||
e.Logger.Fatal(e.Start(":54321"))
|
||||
|
||||
defer db.Close()
|
||||
}
|
||||
|
||||
func healthCheck(c echo.Context) error {
|
||||
|
||||
Reference in New Issue
Block a user