package main import ( "oc-discovery/models" _ "oc-discovery/routers" oclib "cloud.o-forge.io/core/oc-lib" "cloud.o-forge.io/core/oc-lib/logs" beego "github.com/beego/beego/v2/server/web" "github.com/beego/beego/v2/server/web/filter/cors" ) const appname = "oc-discovery" func main() { // Init the oc-lib oclib.Init(appname) // get the right config file o := oclib.GetConfLoader() models.GetConfig().Port = o.GetIntDefault("port", 8080) models.GetConfig().LokiUrl = o.GetStringDefault("lokiurl", "") models.GetConfig().RedisUrl = o.GetStringDefault("redisurl", "localhost:6379") models.GetConfig().RedisPassword = o.GetStringDefault("redispassword", "") models.GetConfig().ZincUrl = o.GetStringDefault("zincurl", "http://localhost:4080") models.GetConfig().ZincLogin = o.GetStringDefault("zinclogin", "admin") models.GetConfig().ZincPassword = o.GetStringDefault("zincpassword", "admin") models.GetConfig().IdentityFile = o.GetStringDefault("identityfile", "./identity.json") models.GetConfig().Defaultpeers = o.GetStringDefault("defaultpeers", "./peers.json") // set oc-lib logger if models.GetConfig().LokiUrl != "" { logs.CreateLogger(appname) } // Normal beego init beego.BConfig.AppName = appname beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080) beego.BConfig.WebConfig.DirectoryIndex = true beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger" beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{ AllowAllOrigins: true, AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, AllowHeaders: []string{"Origin", "Authorization", "Content-Type"}, ExposeHeaders: []string{"Content-Length", "Content-Type"}, AllowCredentials: true, })) beego.Run() }