forked from illidan33/wow_api
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
43 lines (37 loc) · 998 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
40
41
42
43
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/illidan33/wow_api/global"
"github.com/illidan33/wow_api/modules"
"github.com/illidan33/wow_api/public"
"github.com/illidan33/wow_api/routers"
"github.com/illidan33/wow_api/routers/index"
"github.com/jinzhu/gorm"
"github.com/sirupsen/logrus"
)
var (
WowApi *gin.Engine
DB *gorm.DB
)
func main() {
defer func() {
modules.DbConn.Close()
}()
if global.Config.LogLevel != logrus.DebugLevel {
gin.SetMode(gin.ReleaseMode)
}
WowApi = gin.New()
routers.Chart = WowApi.Group("/chart")
routers.Chart.Use(index.AuthMiddleware)
routers.Auth = WowApi.Group("/auth")
routers.Auth.Use(index.AuthMiddleware)
routers.Api = WowApi.Group("/api")
routers.Macro = WowApi.Group("/macro")
routers.MacroOld60 = WowApi.Group("/macro60")
routers.New()
public.New(WowApi)
WowApi.GET("/", index.Index)
WowApi.NoRoute(index.Index)
WowApi.Run(fmt.Sprintf("%s:%d", global.Config.ListenHost, global.Config.ListenPort))
}