主要的go
package main
import (
"net/http"
)
func main() {
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
http.ListenAndServe(":8080", nil)
}
目录 struct :
%GOPATH%/src/project_name/主要的go
%GOPATH%/src/project_name/static/..files and folders ..
即使阅读了文档,我也很难理解http.StripPrefix
到底在这里做什么.
1)如果我删除了http.StripPrefix
,为什么我无法访问localhost:8080/static
?
2)如果我删除该功能,哪个URL会映射到/static
文件夹?