-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
43 lines (40 loc) · 991 Bytes
/
main.go
File metadata and controls
43 lines (40 loc) · 991 Bytes
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"
"net/http"
"os"
"runtime"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/nbtca/notification-center/router"
"github.com/nbtca/notification-center/util"
"github.com/nbtca/notification-center/util/consolefixfunc"
)
func main() {
// util.InitDialer()
// consumer.InitConsumer()
if runtime.GOOS == "windows" { //修复控制台上色
err := consolefixfunc.EnableANSIConsole()
if err != nil {
fmt.Println("Error enabling ANSI console:", err)
}
}
gin.SetMode(gin.ReleaseMode)
err := util.LoadConfig()
if err != nil {
fmt.Println("Error loading config:", err)
os.Exit(1)
}
r := gin.Default()
r.Use(cors.Default()) //跨域
r.GET("/", func(c *gin.Context) { //测试
c.String(http.StatusOK, "200 ok")
})
router.InitWebhook(r)
router.InitWs(r)
if util.Cfg.UseCert {
r.RunTLS(util.Cfg.Bind, util.Cfg.CertFile, util.Cfg.KeyFile) //启动服务
} else {
r.Run(util.Cfg.Bind) //启动服务
}
}