From 23229ef9ef79229cbac479a260f35ee853d7bd6d Mon Sep 17 00:00:00 2001 From: astaxie Date: Sun, 25 May 2014 22:35:20 +0800 Subject: [PATCH] beego: BeegoServerName & beego.Run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BeegoServerName change to beegoServer+Version beego.Run(“:8089”) --- beego.go | 16 ++++++++++++++-- config.go | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/beego.go b/beego.go index 672f0e82..20ab234b 100644 --- a/beego.go +++ b/beego.go @@ -284,8 +284,19 @@ func AddAPPStartHook(hf hookfunc) { } // Run beego application. -// it's alias of App.Run. -func Run() { +// beego.Run() default run on HttpPort +// beego.Run(":8089") +// beego.Run("127.0.0.1:8089") +func Run(params ...string) { + if len(params) > 0 && params[0] != "" { + strs := strings.Split(params[0], ":") + if len(strs) > 0 && strs[0] != "" { + HttpAddr = strs[0] + } + if len(strs) > 1 && strs[1] != "" { + HttpPort, _ = strconv.Atoi(strs[1]) + } + } initBeforeHttpRun() if EnableAdmin { @@ -346,6 +357,7 @@ func initBeforeHttpRun() { middleware.RegisterErrorHandler() } +// this function is for test package init func TestBeegoInit(apppath string) { AppPath = apppath AppConfigPath = filepath.Join(AppPath, "conf", "app.conf") diff --git a/config.go b/config.go index 1a42409b..08988bc0 100644 --- a/config.go +++ b/config.go @@ -142,7 +142,7 @@ func init() { TemplateLeft = "{{" TemplateRight = "}}" - BeegoServerName = "beegoServer" + BeegoServerName = "beegoServer:" + VERSION EnableAdmin = false AdminHttpAddr = "127.0.0.1"