In a Go http server, I can get POST request body. Go net/http package seems to remove GET request body. I know it is better not to use http GET with request body,but I need to handle http GET with request body. Is it possible without changing the standard lib? Please help since I don't want to switch back to C with libevent!
When a client sends a POST with request body, below code will show the body content. But when a client sends a GET with request body, there is nothing in the body.
func handler(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
body, _ := ioutil.ReadAll(r.Body)
log.Printf("body: %v", string(body))
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}