I have a http handler function which saves an email to a database only if that email is not already taken. If the email has already been taken or some other data is invalid I want to redirect back to the form and notify the user where the errors occured.
func validate(w http.ResponseWriter, r *http.Request) {
//query database to check if data r.FormValues were
//valid
//IF form values were not valid redirect back to the
//registration form and pass on data indicating the
//form data was not valid
{
http.Redirect(w, r, "/register", http.StatusFound)
}
}
How on earth do I send data from func validate() to func register()? Is it possible to add some sort of struct to r* http.Request so it gets passed to func register() when http.Redirect() is called?