So, I have this form in an html. It is intended to have a POST request to /subscribe
page:
<html>
<form action="/subscribe" method="post">
First Name: <input type="text" name="first_name" placeholder="Willy"/><br/>
Last Name: <input type="text" name="last_name" placeholder="Warmwood"/><br/>
Email: <input type="email" name="email" placeholder="willy.warwood@gmail.com"/><br/>
<input type="submit" value="Submit"/>
</form>
</html>
Then, I have this router in golang:
http.HandleFunc("/subscribe/", SubscribeHandler)
And this handler in golang:
func SubscribeHandler(w http.ResponseWriter, r *http.Request) {
log.Println(r.Method)
}
But the problem is, it always print GET
.
How to post the form, so the value of r.Method
is POST
?
Thanks