-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (32 loc) · 1.12 KB
/
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
40
41
42
43
44
package main
import (
debug "bitbucket.org/tidepayments/gohelpers/gin"
"github.com/gin-gonic/gin"
"github.com/kardianos/osext"
"github.com/nazwa/galaxy-empires/config"
"github.com/nazwa/galaxy-empires/ge"
"github.com/nazwa/galaxy-empires/handlers"
"github.com/nazwa/galaxy-empires/middleware"
)
var (
ROOT_DIR string
GE *ge.GalaxyEmpires
)
func main() {
ROOT_DIR, _ = osext.ExecutableFolder()
config.LoadConfig(ge.BuildFullPath(ROOT_DIR, "config.json"))
GE = ge.NewGalaxyEmpires(ge.BuildFullPath(ROOT_DIR, "data"), ge.CoordinatesStruct{1, 15, 5})
r := gin.New()
r.Use(gin.Logger())
r.Use(gin.Recovery())
r.Use(middleware.Errors("", "", nil))
debug.AssignDebugHandlers(r.Group("/debug"))
handlers.NewAccountHandler(r.Group("/account"), GE)
handlers.NewPlayerHandler(r.Group("/player", middleware.Authentication([]byte(config.Config.Key))), GE)
handlers.NewPlanetHandler(r.Group("/planet", middleware.Authentication([]byte(config.Config.Key))), GE)
r.Static("/assets", ROOT_DIR+"/web/assets")
r.StaticFile("/", ROOT_DIR+"/web/index.html")
if err := r.Run(":" + config.Config.Port); err != nil {
panic(err)
}
}