func myFunc(w http.ResponseWriter, r *http.Request) { context := make(map[string]string) context["token"] = nosurf.Token(r) if r.Method == "POST" { context["name"] = r.FormValue("name") } templ.Execute(w, context) }
func Index(w http.ResponseWriter, r *http.Request) { context := map[string]string{ "token": nosurf.Token(r), } if r.Method == "POST" { context["name"] = r.FormValue("name") } templ.Execute(w, context) }
func ShowSignupForm(c web.C, w http.ResponseWriter, r *http.Request) { templ.Execute(w, M{ "csrf_token": nosurf.Token(r), // Pass the CSRF token to the template }) }