This is a creation in Article, where the information may have evolved or changed.
Beego frame Good, personal comparison like, the key is also some development tools are very practical, packaged a lot of implementation, do not need to do a lot of work, without considering the premise of efficiency, are acceptable categories.
Custom error page
The Beego default itself with some error pages, which are defined in the Error.go file. Take 404 as an example:
// Show 404 NotFound Error.func NotFound(RW http.Responsewriter, R *http.Request) { T, _ := Template.New("Beegoerrortemp").Parse(ERRTPL) Data := Make(Map[string]Interface{}) Data["Title"] = "Page not Found" Data["Content"] = Template.HTML("<br>the page you had requested has flown the coop." + "<br>perhaps You is here because:" + "<br><br><ul>" + "<br>the page has moved" + "<br>the page no longer exists" + "<br>you were looking for your puppy and got lost" + "<br>you like 404 Pages" + "</ul>") Data["Beegoversion"] = VERSION //RW.Writeheader(http.Statusnotfound) T.Execute(RW, Data)}
In fact, it's easy to make a change yourself:
func Page_not_found(RW http.Responsewriter, R *http.Request){ T,_:= Template.New("404.html").Parsefiles(Beego.Viewspath+"/404.html") Data := Make(Map[string]Interface{}) Data["Content"] = "Page not Found" T.Execute(RW, Data)}func Main() { Beego.ErrorHandler("404",Page_not_found) Beego.Router("/", &Controllers.Maincontroller{}) Beego.Run()}
Modification of the Server field
The server in the HTTP return header always shows Beegoserver, which is too unprofessional to be defined in the Config.go file:
BeegoServerName = "beegoServer"
I originally fork a repo change, and later found that only need to define in the app.conf file can be:
BeegoServerName = ACGSOSERVER
This changes the server field so that other properties can be defined in this way.
golang beego
"!--/.social-share-->