func main() {
http.HandleFunc("/a", func(w http.ResponseWriter, r *http.Request){
s, _ := ioutil.ReadAll(r.Body) //把 body 内容读入字符串 s
fmt.Println(s)
fmt.Fprintf(w, "%s", s) //在返回页面中显示内容。
})
http.ListenAndServe("0.0.0.0:8080", nil)
}
我通过浏览器地址访问 发现并没有任何内容返回
fmt.Println(s) 输出的是一个 []
请问获取请求信息的正确姿势是什么呀 网上找个几个文章试下来都是这种情况
试试用curl调试: