-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (30 loc) · 830 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
package main
import (
"ZhuEngine/config"
"ZhuEngine/router"
"ZhuEngine/site"
"net/http"
"strconv"
"github.com/go-kratos/kratos/v2/log"
)
func main() {
// 读取配置
conf := config.GetConfig()
sites := site.LoadSitesRouter(conf)
site.SiteAutoRun(sites)
log.Info("启动主程序")
handler := &router.Pxy{}
http.Handle("/", handler)
port_string := strconv.Itoa(conf.ZhuEngine.Port)
https_port_string := strconv.Itoa(conf.HTTPS.Port)
if !conf.HTTPS.Enable {
http.ListenAndServe("0.0.0.0:"+port_string, handler)
} else {
if conf.HTTPS.Force {
go http.ListenAndServe("0.0.0.0:"+port_string, &router.ForceHttpsPxy{})
} else {
go http.ListenAndServe("0.0.0.0:"+port_string, handler)
}
log.Fatal(http.ListenAndServeTLS("0.0.0.0:"+https_port_string, conf.HTTPS.Crt, conf.HTTPS.Key, handler))
}
}