mouselog/main.go

49 строки
1.3 KiB
Go

// 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/routers"
"github.com/microsoft/mouselog/trace"
)
func main() {
trace.InitOrmManager()
trace.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)
}