-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (32 loc) · 1003 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
package main
import (
_ "lottery/routers"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
_ "github.com/mattn/go-sqlite3"
"github.com/astaxie/beego/orm"
//"fmt"
)
func init() {
beego.InsertFilter("/v1/admin/*", beego.BeforeRouter, func(ctx *context.Context){
if(ctx.Request.RequestURI == "/v1/admin/login"){
return;
}
var userCookie = ctx.GetCookie("userName")
var userName = ctx.Input.Session("userName")
if userName != userCookie{
//ctx.Redirect(302,"/v1/admin/login")
ctx.Redirect(302, "/")
}
})
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = false
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
orm.RegisterDriver("sqlite", orm.DRSqlite)
orm.RegisterDataBase("default", "sqlite3", "./database/lottery.db")
orm.RunSyncdb("default", false, true)
}
func main() {
beego.Run()
}