I want to redirect user to the page that he has came from after serving a form and taking the input from that form upon successful submission he has to redirect to the same page.
I want this to be done in Golang. Thanks in Advance
I want to redirect user to the page that he has came from after serving a form and taking the input from that form upon successful submission he has to redirect to the same page.
I want this to be done in Golang. Thanks in Advance
You can use
http.Redirect(w, r, r.Header.Get("Referer"), 302)
r.Header.Get("Referer") always contains the referring url for current page ( which is previous url)
Update
As you have said in comment that your are using same url for post and get. In that case it will be update the get url as your refer url.
In this situation you can pass the url as parameter so on success you can redirect user to that url.
For example, If, user gets redirect to the upload page from home page then make url like this,
http://example.com/upload?redir=http://example.com/home
So now you have knowladge from which page the user was landed this page just redirect it to the redir url you got from url.
redirect_url = r.FormValue("redir)
http.Redirect(w, r, redirect_url , 302)