mouselog/main.go

49 строки
1.3 KiB
Go
Исходник Обычный вид История

2020-02-13 07:27:07 +03:00
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
2019-11-04 08:47:22 +03:00
package main
import (
"os"
"github.com/astaxie/beego"
"github.com/astaxie/beego/plugins/cors"
2020-02-05 18:51:12 +03:00
"github.com/microsoft/mouselog/routers"
2019-11-04 08:47:22 +03:00
2019-12-10 15:47:27 +03:00
_ "github.com/microsoft/mouselog/routers"
2020-01-15 10:40:58 +03:00
"github.com/microsoft/mouselog/trace"
2019-11-04 08:47:22 +03:00
)
func main() {
2020-01-15 10:40:58 +03:00
trace.InitOrmManager()
trace.InitMapMutexes()
2020-01-15 10:40:58 +03:00
2019-11-04 08:47:22 +03:00
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
AllowMethods: []string{"GET", "PUT", "PATCH"},
AllowHeaders: []string{"Origin"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
}))
2020-02-05 18:51:12 +03:00
//beego.DelStaticPath("/static")
beego.SetStaticPath("/static", "web/build/static")
2020-02-15 05:32:17 +03:00
beego.SetStaticPath("/screenshots", "static/screenshots")
2020-02-05 18:51:12 +03:00
// 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"
2019-11-04 08:47:22 +03:00
beego.BConfig.WebConfig.Session.SessionProviderConfig = "./tmp"
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600 * 24 * 365
port := beego.AppConfig.String("httpport")
2019-11-04 08:47:22 +03:00
if len(os.Args) > 1 {
port = os.Args[1]
}
beego.Run("0.0.0.0:" + port)
}