- Install the github.com/gorilla/csrf and github.com/gorilla/mux packages using the go get command, as follows:
$ go get github.com/gorilla/csrf$ go get github.com/gorilla/mux
- Create sign-up.html with name and email input text fields and an action that gets called whenever an HTML form is submitted, as follows:
<html> <head> <title>Sign Up!</title> </head> <body> <form method="POST" action="/post" accept-charset="UTF-8"> <input type="text" name="name"> <input type="text" name="email"> {{ .csrfField }} <input type="submit" value="Sign up!"> </form> </body></html>
- Create prevent-csrf.go, where we create a signUp handler that renders a signup HTML form and a post handler that gets executed whenever an HTML form is submitted ...