forked from coaidev/coai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (36 loc) · 742 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
package main
import (
"chat/addition"
"chat/admin"
"chat/auth"
"chat/cli"
"chat/manager"
"chat/manager/conversation"
"chat/middleware"
"chat/utils"
"fmt"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
)
func main() {
viper.SetConfigFile("config.yaml")
if err := viper.ReadInConfig(); err != nil {
panic(err)
}
if cli.Run() {
return
}
app := gin.Default()
middleware.RegisterMiddleware(app)
{
auth.Register(app)
admin.Register(app)
manager.Register(app)
addition.Register(app)
conversation.Register(app)
}
gin.SetMode(utils.Multi[string](viper.GetBool("debug"), gin.DebugMode, gin.ReleaseMode))
if err := app.Run(fmt.Sprintf(":%s", viper.GetString("server.port"))); err != nil {
panic(err)
}
}