-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
executable file
·45 lines (36 loc) · 946 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
44
45
package main
import (
"fmt"
"net/http"
"webstack/lib"
"webstack/router"
"github.com/gin-gonic/gin"
ginsession "github.com/go-session/gin-session"
)
func init() {
lib.LoadConfiguration()
lib.LoadRoutes()
}
func main() {
config := lib.GlobalConfig
app := gin.Default()
//gin.SetMode(gin.ReleaseMode)
app.Use(ginsession.New())
skinDir := "./skin"
app.LoadHTMLFiles("./admin/404.tpl", "./admin/login.tpl", fmt.Sprintf("%v/%v/index.html", skinDir, lib.GlobalConfig.Service.Skin))
app.Static("/skin", "./skin")
app.NoRoute(func(ctx *gin.Context) {
// 实现内部重定向
ctx.HTML(http.StatusNotFound, "404.html", gin.H{})
})
router.InitFrontend(app)
router.InitBackend(app)
addr := ":" + config.Service.Port
if config.Service.SSLMode {
csrKey := fmt.Sprintf("./data/%s", config.Service.Csr)
priKey := fmt.Sprintf("./data/%s", config.Service.Key)
app.RunTLS(addr, csrKey, priKey)
} else {
app.Run(addr)
}
}