my routers/default.go, I'm trying to use the original Go solution, but failed, this code can't compiled. I don't know how to replace the router with faviconHandler:
func faviconHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/img/favicon.ico")
}
func init() {
beego.Router("/", &controllers.MainController{})
beego.Router("/favicon.ico", faviconHandler) // this doesn't work
}
I found there is at least one method: embedded into index.tpl.
bee new newapp
cd $GOPATH/src/newapp
bee run # you will see the favicon of a bee.
Modify the embedded text in $GOPATH/src/view/index.tpl to yours, here is a linux script
cd views
# assume you have put the favicon.ico in this directory
base64 -w0 favicon.ico > favicon.b64
cp index.tpl index.tpl.old
sed 's/base64,.*"/base64,\n"/' index.tpl.old | sed '7r favicon.b64' > index.tpl
# rm favicon.ico favicon.b64 index.tpl.old # remove the temp file