func mainCommands() { rootCmd := &cobra.Command{ Use: "openlandings", Run: func(cmd *cobra.Command, args []string) { beego.Run() }, } cmdWeb := &cobra.Command{ Use: "web", Short: "Start the web server", Run: func(cmd *cobra.Command, args []string) { beego.Run() }, } cmdSiteCollector := &cobra.Command{ Use: "collect", Short: "Collect the site templates from the host", Run: func(cmd *cobra.Command, args []string) { // collector.Run() }, } rootCmd.AddCommand(cmdWeb, cmdSiteCollector) if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(-1) } }
func main() { beego.SessionOn = true beego.SetStaticPath("/img", "static/img") beego.SetStaticPath("/css", "static/css") beego.SetStaticPath("/js", "static/js") beego.Run() }
func main() { beego.DirectoryIndex = true beego.StaticDir["/beeapi"] = "beeapi" beego.Errorhandler("404", loadPageNotFound) beego.Errorhandler("show-database-error", loadDatabaseError) beego.Run() }
func main() { initialize() beego.Info(beego.AppName, APP_VER) beego.InsertFilter("/docs/images/:all", beego.BeforeRouter, routers.DocsStatic) if !routers.IsPro { beego.SetStaticPath("/static_source", "static_source") beego.DirectoryIndex = true } beego.SetStaticPath("/products/images", "products/images/") // Register routers. beego.Router("/", &routers.HomeRouter{}) beego.Router("/community", &routers.CommunityRouter{}) beego.Router("/quickstart", &routers.QuickStartRouter{}) beego.Router("/video", &routers.VideoRouter{}) beego.Router("/products", &routers.ProductsRouter{}) beego.Router("/team", &routers.PageRouter{}) beego.Router("/about", &routers.AboutRouter{}) beego.Router("/donate", &routers.DonateRouter{}) beego.Router("/docs/", &routers.DocsRouter{}) beego.Router("/docs/:all", &routers.DocsRouter{}) beego.Router("/blog", &routers.BlogRouter{}) beego.Router("/blog/:all", &routers.BlogRouter{}) // Register template functions. beego.AddFuncMap("i18n", i18n.Tr) beego.Run() }
func main() { models.InitDB(true, true) beego.SetLogFuncCall(true) beego.AutoRender = false beego.Run() }
func main() { initialize() go catchExit() beego.Info(beego.AppName, APP_VER) // Register routers. beego.Router("/", &routers.HomeRouter{}) beego.Router("/refresh", &routers.RefreshRouter{}) beego.Router("/search", &routers.SearchRouter{}) beego.Router("/index", &routers.IndexRouter{}) // beego.Router("/label", &routers.LabelsRouter{}) beego.Router("/function", &routers.FuncsRouter{}) beego.Router("/example", &routers.ExamplesRouter{}) beego.Router("/about", &routers.AboutRouter{}) beego.Router("/api/v1/badge", &routers.ApiRouter{}, "get:Badge") // Register template functions. beego.AddFuncMap("i18n", i18n.Tr) beego.AddFuncMap("isHasEleS", isHasEleS) beego.AddFuncMap("isHasEleE", isHasEleE) beego.AddFuncMap("isNotEmptyS", isNotEmptyS) // "robot.txt" beego.Router("/robots.txt", &routers.RobotRouter{}) // For all unknown pages. beego.Router("/:all", &routers.HomeRouter{}) // Static path. beego.SetStaticPath("/public", "public") beego.Run() }
func main() { orm.Debug = true orm.RunSyncdb("default", false, true) /* 设置Session配置*/ beego.SessionOn = false beego.Run() }
func main() { core.Router_register() sso.Router_register() im.Router_register() schedule.Router_register() pay.Router_register() fmt.Println(beego.AppConfig.String("mysqluser")) fmt.Println(beego.AppConfig.String("mysqlpass")) fmt.Println(beego.AppConfig.String("mysqlurls")) fmt.Println(beego.AppConfig.String("mysqldb")) var FilterUser = func(ctx *context.Context) { if v := ctx.Input.Query("access_token"); v != "" { //data := "ok" fmt.Println(v) //ctx.Output.Json(data, false, true) } else { data := `{"error","err"}` ctx.Output.Json(data, false, true) } } beego.InsertFilter("*", beego.BeforeRouter, FilterUser) beego.Run() }
// main starts the application func main() { beego.ErrorController(&controllers.ErrorController{}) beego.Router("/", &controllers.MainController{}) beego.Router("/streams", &controllers.StreamController{}) beego.Run() }
func main() { beego.AddFuncMap("Preview", common.Preview) beego.AddFuncMap("GetId", common.GetId) beego.AddFuncMap("LoadTimes", common.LoadTimes) beego.AddFuncMap("GetTagSlug", common.GetTagSlug) beego.Run() }
func main() { if beego.AppConfig.String("runmode") == "dev" { orm.Debug = false } beego.Run() }
func main() { beego.SessionOn = true beego.InsertFilter("/appadmin/*", beego.BeforeRouter, auth.Basic("youradminname", "YourAdminPassword")) beego.InsertFilter("/hosts", beego.BeforeRouter, controllers.FilterLogin) beego.InsertFilter("/hosts/*", beego.BeforeRouter, controllers.FilterLogin) beego.Run() }
func main() { if len(os.Args) > 1 { switch len(os.Args) { case 2: if os.Args[1] == "init" { models.Install() } } return } docSwitch, err := beego.AppConfig.Bool("EnableDocs") if err != nil { log.Fatalln(err) } if docSwitch { beego.DirectoryIndex = true beego.StaticDir["/swagger"] = "swagger" } monitorSwitch, err := beego.AppConfig.Bool("EnableMonitor") if err != nil { log.Fatalln(err) } if monitorSwitch { beego.StaticDir["/inspinia"] = "inspinia" } beego.Run() }
func main() { conf := sockjs.NewConfig() sockjshandler := sockjs.NewHandler("/chat", chatHandler, conf) beego.Router("/", &MainController{}) beego.RouterHandler("/chat/:info(.*)", sockjshandler) beego.Run() }
func main() { initialize() beego.Info("AppPath:", beego.AppPath) if setting.IsProMode { beego.Info("Product mode enabled") } else { beego.Info("Develment mode enabled") } beego.Info(beego.AppName, setting.APP_VER, setting.AppUrl) //initialize the routers routers.Initialize() if !setting.IsProMode { beego.SetStaticPath("/static_source", "static_source") beego.DirectoryIndex = true } if beego.RunMode == "dev" { //enable debug for orm //orm.Debug = false orm.Debug = true } // For all unknown pages. beego.Run() }
func main() { beego.Router("/", &controllers.MainController{}) beego.Router("/push/create", &controllers.IndexController{}) beego.Router("/push/test", &controllers.TestController{}) beego.Router("/push/query", &controllers.QueryController{}) beego.Run() }
func main() { orm.Debug = true orm.RunSyncdb("default", false, true) //models.AddUser() //models.AddTotalAndWin("martin", true) beego.Run() }
func main() { err := orm.RunSyncdb("default", false, false) if err != nil { beego.Error(err) } beego.Run() }
func main() { initialize() beego.Info(beego.AppName, APP_VER) beego.AddFilter("/docs/images/:all", "BeforeRouter", routers.DocsStatic) // Register routers. beego.Router("/", &routers.HomeRouter{}) beego.Router("/community", &routers.CommunityRouter{}) beego.Router("/quickstart", &routers.QuickStartRouter{}) beego.Router("/team", &routers.PageRouter{}) beego.Router("/about", &routers.AboutRouter{}) beego.Router("/donate", &routers.DonateRouter{}) beego.Router("/docs/", &routers.DocsRouter{}) beego.Router("/docs/:all", &routers.DocsRouter{}) beego.Router("/blog", &routers.BlogRouter{}) beego.Router("/blog/:all", &routers.BlogRouter{}) // beego.Router("/samples", &routers.SamplesRouter{}) // beego.Router("/samples/:all", &routers.SamplesRouter{}) // Register template functions. beego.AddFuncMap("i18n", i18n.Tr) beego.Run() }
func main() { orm.Debug = true orm.RunSyncdb("default", true, true) beego.Router("/", &controllers.MainController{}) beego.Run() }
func main() { version() fmt.Printf("built on %s\n", BuildTime()) flag.Parse() cfg := NewMonitorConfig(*InputConfFile) err := cfg.LoadConfig() if err != nil { log.Error(err.Error()) return } server, err := libnet.Listen(cfg.TransportProtocols, cfg.Listen) if err != nil { log.Error(err.Error()) return } log.Info("server start: ", server.Listener().Addr().String()) m := NewMonitor(cfg) //TODO not use go m.subscribeChannels() go server.Serve(func(session *libnet.Session) { }) beego.Router("api/v1/monitor", &controllers.MonitorController{}) //beego.SetStaticPath("/views", "/mh/mygo/src/github.com/oikomi/FishChatServer/monitor/views") beego.SetStaticPath("/views", "views") beego.Run() }
func main() { glog.SetLogDirs(".") glog.SetLogToStderr(true) conf := controllers.Gconf beego.Get("/federation", func(ctx *context.Context) { federation(ctx, conf) }) beego.Get("/ripple.txt", func(ctx *context.Context) { f, err := os.Open("ripple.txt") if err != nil { glog.Fatal(err) } io.Copy(ctx.ResponseWriter, f) f.Close() }) beego.Get("/quote", func(ctx *context.Context) { u := "http://" + conf.Host + "/api/quote?" + ctx.Request.URL.RawQuery glog.Infoln(u) r, err := http.Get(u) if err != nil { glog.Errorln(err) return } io.Copy(ctx.ResponseWriter, r.Body) r.Body.Close() }) beego.Run() }
func main() { if beego.RunMode == "dev" { beego.DirectoryIndex = true beego.StaticDir["../client"] = "client" } beego.Run() }
func main() { initialize() if utils.IsProMode { beego.Info("Product mode enabled") } else { beego.Info("Development mode enabled") } beego.Info(beego.AppName, utils.APP_VER, utils.AppUrl) if !utils.IsProMode { beego.SetStaticPath("/static_source", "static_source") } // Register routers. general := new(routers.GeneralRouter) beego.Router("/", general, "get:PublicHome") beego.Router("/home", general, "get:UserHome") beego.Router("/acknowledgements", general, "get:Acknowledgements") user := new(routers.UserRouter) beego.Router("/u/:email", user, "get:Home") login := new(routers.LoginRouter) beego.Router("/login", login, "post:Login") beego.Router("/logout", login, "get:Logout") register := new(routers.RegisterRouter) beego.Router("/register", register, "post:Register") beego.Router("/active/success", register, "get:ActiveSuccess") beego.Router("/active/:code([0-9a-zA-Z]+)", register, "get:Active") settings := new(routers.SettingsRouter) beego.Router("/settings/profile", settings, "get:Profile;post:ProfileSave") forgot := new(routers.ForgotRouter) beego.Router("/forgot", forgot) beego.Router("/reset/:code([0-9a-zA-Z]+)", forgot, "get:Reset;post:ResetPost") adminDashboard := new(routers.AdminDashboardRouter) beego.Router("/admin", adminDashboard) routes := map[string]beego.ControllerInterface{ "user": new(routers.UserAdminRouter), //Can place more routers to also use generic List/Save/Update/Delete urls below } for name, router := range routes { beego.Router(fmt.Sprintf("/admin/:model(%s)", name), router, "get:List") beego.Router(fmt.Sprintf("/admin/:model(%s)/:id(new)", name), router, "get:Create;post:Save") beego.Router(fmt.Sprintf("/admin/:model(%s)/:id([0-9]+)", name), router, "get:Edit;post:Update") beego.Router(fmt.Sprintf("/admin/:model(%s)/:id([0-9]+)/:action(delete)", name), router, "get:Confirm;post:Delete") } // "robot.txt" beego.Router("/robot.txt", &routers.RobotRouter{}) // For all unknown pages. beego.Run() }
func main() { beego.BConfig.RunMode = "prod" beego.Router("/json", &JsonController{}) beego.Router("/db", &DBController{}) beego.Router("/plaintext", &PlaintextController{}) beego.Run() }
func main() { beego.Info(beego.AppName, APP_VER) // Register routers. beego.Router("/", &controllers.AppController{}) // Indicate AppController.Join method to handle POST requests. beego.Router("/join", &controllers.AppController{}, "post:Join") // Long polling. beego.Router("/lp", &controllers.LongPollingController{}, "get:Join") beego.Router("/lp/post", &controllers.LongPollingController{}) beego.Router("/lp/fetch", &controllers.LongPollingController{}, "get:Fetch") // WebSocket. beego.Router("/ws", &controllers.WebSocketController{}) beego.Router("/ws/join", &controllers.WebSocketController{}, "get:Join") // Register template functions. beego.AddFuncMap("i18n", i18n.Tr) // serve securely if the certificates are present _, certErr := os.Stat(servingCertFile) _, keyErr := os.Stat(servingKeyFile) if certErr == nil && keyErr == nil && len(servingCertFile) > 0 && len(servingKeyFile) > 0 { beego.HttpCertFile = servingCertFile beego.HttpKeyFile = servingKeyFile beego.EnableHttpTLS = true } beego.Run() }
func main() { if beego.RunMode == "dev" { beego.DirectoryIndex = true beego.StaticDir["/swagger"] = "swagger" } beego.Run() }
func main() { //start moitor services.MonitorInit() beego.Router("/", &controllers.MainController{}) beego.Run() }
func main() { beego.BeeLogger.Info("!!!!!!") db, err := sqlx.Open("mysql", "root:asharov@tcp(db:3306)/blog3?charset=utf8") if err != nil { panic(err) } components.App.Db = db //websocket server wampServer := wamp.NewServer() beego.BeeLogger.Info("Running WS server wait for client requests") go wampServer.ListenAndServe() //run upgrade server, for upgrade http to ws addr := ":8081" upgradeServer := &http.Server{ Addr: addr, Handler: wampServer, } beego.BeeLogger.Info("Running Upgrade server on %s", addr) go upgradeServer.ListenAndServe() //run usual web app beego.Run() }
func main() { // 定期执行计划任务 go controllers.PlanTask() // 运行 beego.Run() }