1. Customizing ports and environments from the command line
First use flag to extract the parameters, if you want the environment, the reverse injection in,
If it is a port, hit the Beego. In the Run function.
2, in the router URL parsing, if the URL contains-the underlined, with a strict string is not matched.
This string qualifier needs to be removed.
Package Mainimport ("Flag" "FMT" _ "prismlogapi/routers" "Github.com/astaxie/beego" "Github.com/astaxie/beego/orm" _ " Github.com/go-sql-driver/mysql ") Func main () {//orm. Debug = TrueRunMode: = flag. String ("RunMode", "Dev", "Runmode:default is Dev") port: = Flag. String ("Port", "9527", "Port:default is 9527") flag. Parse () Beego. Bconfig.runmode = *runmodeFmt. Println (Beego. Bconfig.runmode) fmt. PRINTLN (port) if Beego. Bconfig.runmode = = "Dev" {Beego. BConfig.WebConfig.DirectoryIndex = Truebeego. bconfig.webconfig.staticdir["/swagger"] = "Swagger"}dbhost: = Beego. Appconfig.string ("Dbhost") Dbport: = Beego. Appconfig.string ("Dbport") Dbuser: = Beego. Appconfig.string ("Dbuser") Dbpassword: = Beego. Appconfig.string ("Dbpassword") db: = Beego. Appconfig.string ("DB") Orm. Registerdriver ("MySQL", Orm.) DRMYSQL) Conn: = Dbuser + ":" + Dbpassword + "@tcp (" + Dbhost + ":" + Dbport + ")/" + DB + "? Charset=utf8" FMT. PRINTLN (conn) Orm. RegisterDatabase ("Default", "MySQL", conn) Orm. Setmaxidleconns ("Default", "+") orm. Setmaxopenconns ("Default", 2000)Beego. Run (":" + *port)}
@Title get logs for a specific deployment//@Description return multiple logs//@Param ID Path int true "The key for Staticblock"//@Success $ {Object} mode Ls. prismlog//@router /:app/:d epverion:string/:order:int/ [Get]func (U *prismlogcontroller) Getbyappdepord () { App: = u.getstring (": App") Depverion: = U.getstring (":d epverion") Order, _: = U.getint (": Order") fmt. Println (app, depverion, Order, "") s: = models. Getprismlogbyappdepord (app, depverion, order) u.data["json"] = su. Servejson ()
Beego Two tips: Customizing ports and environments from the command line with an underscore in the URL