Example #1
0
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)
}
Example #2
0
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)
}
Example #3
0
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
	})
}