/
main.go
39 lines (31 loc) · 952 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"github.com/gin-gonic/gin"
"github.com/l12u/gamemaster/internal/handler"
"github.com/l12u/gamemaster/internal/middleware"
"k8s.io/klog"
"time"
)
func main() {
klog.Infoln("Hello World!")
handler.SetupProvider()
handler.SetupBoardConfigAuto()
gin.DisableConsoleColor()
r := gin.New()
r.Use(middleware.Logger(3 * time.Second))
r.Use(gin.Recovery())
r.POST("/games", handler.PostGame)
r.GET("/games", handler.GetAllGames)
r.GET("/games/:id", handler.GetGame)
r.DELETE("/games/:id", handler.DeleteGame)
r.POST("/games/:id/players", handler.PostPlayerToGame)
r.PUT("/games/:id/players/:pId", handler.PutPlayerToGame)
r.DELETE("/games/:id/players/:pId", handler.DeletePlayerFromGame)
r.PUT("/games/:id/state", handler.PutState)
r.GET("/boards", handler.GetAllBoards)
r.GET("/boards/:type", handler.GetBoard)
r.GET("/healthz", func(c *gin.Context) {
c.JSON(200, gin.H{"status": "UP"})
})
_ = r.Run()
}