Beego Two tips: Customizing ports and environments from the command line with an underscore in the URL

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.