- Install github.com/gorilla/mux and github.com/gorilla/securecookie using the go get command, as follows:
$ go get github.com/gorilla/mux$ go get github.com/gorilla/securecookie
- Create home.html inside the templates directory, as follows:
$ mkdir templates && cd templates && touch home.html
- Copy the following content to home.html:
<html> <head> <title></title> </head> <body> <h1>Welcome {{.userName}}!</h1> <form method="post" action="/logout"> <button type="submit">Logout</button> </form> </body></html>
In the preceding template, we defined a placeholder, {{.userName}}, whose values will be substituted by the template engine at runtime and a Logout button. By clicking the Logout button, the client will make a POST call ...