dqiatvbi61502 2017-06-23 07:41 采纳率: 0%
浏览 634
已采纳

如何在beego上添加favicon.ico?

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                 
}
  • 写回答

2条回答 默认 最新

  • dongqi4085 2017-07-04 03:39
    关注

    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,
    "/' index.tpl.old | sed '7r favicon.b64' > index.tpl
    # rm favicon.ico favicon.b64  index.tpl.old # remove the temp file
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog