Go 绑定带前缀的静态目录
🏒

Go 绑定带前缀的静态目录

时间
Sep 23, 2022
来源
原创
访问 http://127.0.0.1:40000/aaa/1.txt,实际访问的是 c:\\bbb\1.txt
http.Handle("/aaa/", http.StripPrefix("/aaa", http.FileServer(http.Dir("c:\\bbb")))) http.ListenAndServe(":40000", nil)
http.StripPrefix 需要注意,如果不去除 /aaa,实际是以 c:\\bbb\aaa\\1.txt 路径查找。