Hi all,
Was wondering if you could help me with the following issue i have…
when i send a POST request to my httpHandler, it parses the form data fine and displays it… a get method does not.
can someone please explain why, and maybe provide an example? I’m taking it a GET method send a request to the server to receive information… rather than sending form data to the server… but i need a way around this, without sending a post request with a formvalue for method…
code:
func httpHandler(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
k := r.FormValue("key")
v := r.FormValue("value")
dt := r.FormValue("datatype")
fmt.Fprintf(w, "httphandler, %v, %v", k, v)
nk := r.FormValue("newkey")
nv := r.FormValue("newvalue")
fmt.Fprintf(w, "httphandler2, %v, %v", k, v)
switch r.Method {
case http.MethodPost:
handlePost(w, k, v, dt)
case http.MethodGet:
handleGet(w, k, v)
case http.MethodPut:
handlePut(w, k, v, nk, nv, dt)
case http.MethodDelete:
handleGet(w, k, v)
}
}
so when i run this with a get method, it sends nil values to the handleGet(w, k, v) function