Golang web 隐藏真实文件地址?

andyxiaqi · · 1001 次点击
是返回文件呀,主要是下载
#2
更多评论
这不就是路由吗
#1
``` package main import ( "io/ioutil" "log" "net/http" ) func main() { http.HandleFunc("/public/image/img1", a) err := http.ListenAndServe(":8080", nil) if err != nil { log.Fatal("ListenAndServe: ", err) } } func a(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "image/jpeg") b, _ := ioutil.ReadFile("a.png") w.Write(b) } ```
#3