-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathmain.go
48 lines (36 loc) · 1.32 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
46
47
48
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package main
import (
"os"
"github.com/astaxie/beego"
"github.com/astaxie/beego/plugins/cors"
"github.com/microsoft/mouselog/routers"
"github.com/microsoft/mouselog/object"
_ "github.com/microsoft/mouselog/routers"
)
func main() {
object.InitOrmManager()
object.InitMapMutexes()
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
AllowMethods: []string{"GET", "PUT", "PATCH"},
AllowHeaders: []string{"Origin"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
}))
//beego.DelStaticPath("/static")
beego.SetStaticPath("/static", "web/build/static")
beego.SetStaticPath("/screenshots", "static/screenshots")
// https://studygolang.com/articles/2303
beego.InsertFilter("/", beego.BeforeRouter, routers.TransparentStatic) // must has this for default page
beego.InsertFilter("/*", beego.BeforeRouter, routers.TransparentStatic)
beego.BConfig.WebConfig.Session.SessionProvider = "file"
beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp"
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365
port := beego.AppConfig.String("httpport")
if len(os.Args) > 1 {
port = os.Args[1]
}
beego.Run("0.0.0.0:" + port)
}