I am trying to send some data that is gzipped on a post to a golang server and use it gunzipped in the post. Basically, i do the following input
curl -X POST -H "Content-Encoding: gzip" -d @helloworld.gz http://myapp/
on the server side
func PostEndpoint(w http.ResponseWriter, req *http.Request) {
gunzip, err := gzip.NewReader(req.Body)
if err != nil {
log.Println("error unzip: ",err)
}
body , _ := ioutil.ReadAll(gunzip)
}
I keep getting a EOF error. I tried to print the raw bytes with ioutil.ReadAll(req.Body)
and it is not really the full data i sent in from curl.
Is there something that needs to be configured to mux? right now i create it as
router := mux.NewRouter()
router.HandleFunc("/", GetEndpoint).Methods("GET")
router.HandleFunc("/", PostEndpoint).Methods("POST")
log.Fatal(http.ListenAndServe(":80", router))