I am serving index.html through go. However, depending upon certain parameters that will be send through the page, go should redirect successfully to a different page. I am getting the below error while trying to execute the code.
http: multiple response.WriteHeader calls
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, r.URL.Path[1:])
fmt.Println(r.FormValue("login"))
if r.FormValue("signup") == "signup" {
signup(w, r)
} else if r.FormValue("login") == "login" {
if login(w, r) {
if r.Method == "POST" {
fmt.Println("I m here")
http.Redirect(w, r, "http://localhost:8080/home.html" (http://localhost:8080/home.html') , http.StatusSeeOther)
}
}
}
})
var port string
if port = os.Getenv("PORT"); len(port) == 0 {
port = DEFAULT_PORT
}
log.Fatal(http.ListenAndServe(":"+port, nil))
}