jjzjj

httpReponseWriter

全部标签

css - Golang : io. Copy(httpReponseWriter, os.File) 与 http.ServeFile()

在意识到http包有一个内置的ServeFile方法之前,我或多或少地实现了一个静态处理程序,如下所示:funcStaticHandler(whttp.ResponseWriter,r*http.Request){filename:=mux.Vars(r)["static"]//usinggorilla/muxf,err:=os.Open(fmt.Sprintf("%v/static/%v",webroot,filename))iferr!=nil{http.NotFound(w,r)return}deferf.Close()io.Copy(w,f)}并且,例如,以这种方式链接我的样式