From d7889bf3eab55f56d2ca94c462ca130fde705871 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 13 Feb 2025 19:05:22 +0800 Subject: http_handle_*.go: Fix http.Error calls Previously when I was converting the fmt.Fprintln calls into http.Error, there was a mistake in my sed command which caused some of the messages to have double colons. This should fix them. --- http_handle_login.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'http_handle_login.go') diff --git a/http_handle_login.go b/http_handle_login.go index 70a8c8b..2d2dbf6 100644 --- a/http_handle_login.go +++ b/http_handle_login.go @@ -16,7 +16,7 @@ func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any) if r.Method != "POST" { err := templates.ExecuteTemplate(w, "login", params) if err != nil { - http.Error(w, "Error rendering template:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error rendering template: "+err.Error(), http.StatusInternalServerError) } return } @@ -32,17 +32,17 @@ func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any) params["login_error"] = "Unknown username" err := templates.ExecuteTemplate(w, "login", params) if err != nil { - http.Error(w, "Error rendering template:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error rendering template: "+err.Error(), http.StatusInternalServerError) } return } - http.Error(w, "Error querying user information:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error querying user information: "+err.Error(), http.StatusInternalServerError) return } match, err := argon2id.ComparePasswordAndHash(password, password_hash) if err != nil { - http.Error(w, "Error comparing password and hash:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error comparing password and hash: "+err.Error(), http.StatusInternalServerError) return } @@ -50,7 +50,7 @@ func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any) params["login_error"] = "Invalid password" err := templates.ExecuteTemplate(w, "login", params) if err != nil { - http.Error(w, "Error rendering template:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error rendering template: "+err.Error(), http.StatusInternalServerError) return } return @@ -75,7 +75,7 @@ func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any) _, err = database.Exec(r.Context(), "INSERT INTO sessions (user_id, session_id) VALUES ($1, $2)", user_id, cookie_value) if err != nil { - http.Error(w, "Error inserting session:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error inserting session: "+err.Error(), http.StatusInternalServerError) return } -- cgit v1.2.3