我有这个目录结构,我正在使用 Gorilla mux:
目录结构
layout
stylesheets
log.css
log.html
twitter.go
按照这里的建议:http : //www.shakedos.com/2014/Feb/08/serving-static-files-with-go.html我这样做了:
var router = mux.NewRouter()
func ServeStatic(router *mux.Router, staticDirectory string) {
staticPaths := map[string]string{
"styles": staticDirectory + "stylesheets",
}
for pathName, pathValue := range staticPaths {
pathPrefix := "/" + pathName + "/"
router.PathPrefix(pathPrefix).Handler(http.StripPrefix(pathPrefix,
http.FileServer(http.Dir(pathValue))))
}
}
var staticDirectory = "/layout/"
func main() {
(//other code)
ServeStatic(router, staticDirectory)
}
我仍然无法链接 CSS 文件。我究竟做错了什么?
慕田峪9158850
饮歌长啸
相关分类