-
Notifications
You must be signed in to change notification settings - Fork 383
/
main.go
45 lines (38 loc) · 1.35 KB
/
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 (
"github.com/astaxie/beego"
"github.com/lisijie/webcron/app/controllers"
"github.com/lisijie/webcron/app/jobs"
_ "github.com/lisijie/webcron/app/mail"
"github.com/lisijie/webcron/app/models"
"html/template"
"net/http"
)
const VERSION = "1.0.0"
func main() {
models.Init()
jobs.InitJobs()
// 设置默认404页面
beego.ErrorHandler("404", func(rw http.ResponseWriter, r *http.Request) {
t, _ := template.New("404.html").ParseFiles(beego.BConfig.WebConfig.ViewsPath + "/error/404.html")
data := make(map[string]interface{})
data["content"] = "page not found"
t.Execute(rw, data)
})
// 生产环境不输出debug日志
if beego.AppConfig.String("runmode") == "prod" {
beego.SetLevel(beego.LevelInformational)
}
beego.AppConfig.Set("version", VERSION)
// 路由设置
beego.Router("/", &controllers.MainController{}, "*:Index")
beego.Router("/login", &controllers.MainController{}, "*:Login")
beego.Router("/logout", &controllers.MainController{}, "*:Logout")
beego.Router("/profile", &controllers.MainController{}, "*:Profile")
beego.Router("/gettime", &controllers.MainController{}, "*:GetTime")
beego.Router("/help", &controllers.HelpController{}, "*:Index")
beego.AutoRouter(&controllers.TaskController{})
beego.AutoRouter(&controllers.GroupController{})
beego.BConfig.WebConfig.Session.SessionOn = true
beego.Run()
}