aboutsummaryrefslogtreecommitdiff
path: root/http_handle_index.go
diff options
context:
space:
mode:
Diffstat (limited to 'http_handle_index.go')
-rw-r--r--http_handle_index.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/http_handle_index.go b/http_handle_index.go
index bbb10d8..8066a03 100644
--- a/http_handle_index.go
+++ b/http_handle_index.go
@@ -1,14 +1,13 @@
package main
import (
- "fmt"
"net/http"
)
func handle_index(w http.ResponseWriter, r *http.Request, params map[string]any) {
rows, err := database.Query(r.Context(), "SELECT name FROM groups")
if err != nil {
- fmt.Fprintln(w, "Error querying groups: " + err.Error())
+ http.Error(w, "Error querying groups: : "+err.Error(), http.StatusInternalServerError)
return
}
defer rows.Close()
@@ -17,14 +16,14 @@ func handle_index(w http.ResponseWriter, r *http.Request, params map[string]any)
for rows.Next() {
var groupName string
if err := rows.Scan(&groupName); err != nil {
- fmt.Fprintln(w, "Error scanning group name: " + err.Error())
+ http.Error(w, "Error scanning group name: : "+err.Error(), http.StatusInternalServerError)
return
}
groups = append(groups, groupName)
}
if err := rows.Err(); err != nil {
- fmt.Fprintln(w, "Error iterating over rows: " + err.Error())
+ http.Error(w, "Error iterating over rows: : "+err.Error(), http.StatusInternalServerError)
return
}
@@ -32,7 +31,7 @@ func handle_index(w http.ResponseWriter, r *http.Request, params map[string]any)
err = templates.ExecuteTemplate(w, "index", params)
if err != nil {
- fmt.Fprintln(w, "Error rendering template: " + err.Error())
+ http.Error(w, "Error rendering template: : "+err.Error(), http.StatusInternalServerError)
return
}
}