go语言gorilla/mux添加favicon.ico 静态文件
router = mux.NewRouter()
router.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "image/x-icon")
//favicon.ico相对main.go的路径
http.ServeFile(w, r, "./favicon.ico")
}).Methods("GET")
如果页面不展示记得加个参数防止缓存, 0.0坑死
<link rel="icon" type="image/x-icon" href="/favicon.ico?v=2">
网友评论