From 14326ba9be276d2649b4681d3ebed1c32f65013f Mon Sep 17 00:00:00 2001 From: Runxi Yu <me@runxiyu.org> Date: Thu, 13 Feb 2025 01:28:35 +0800 Subject: _header.html: Add header --- http_handle_index.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'http_handle_index.go') diff --git a/http_handle_index.go b/http_handle_index.go index bf36f98..4448272 100644 --- a/http_handle_index.go +++ b/http_handle_index.go @@ -4,10 +4,7 @@ import ( "net/http" ) -func handle_index(w http.ResponseWriter, r *http.Request) { - data := make(map[string]any) - data["global"] = global_data - +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 { _, _ = w.Write([]byte("Error querying groups: " + err.Error())) @@ -30,9 +27,9 @@ func handle_index(w http.ResponseWriter, r *http.Request) { return } - data["groups"] = groups + params["groups"] = groups - err = templates.ExecuteTemplate(w, "index", data) + err = templates.ExecuteTemplate(w, "index", params) if err != nil { _, _ = w.Write([]byte("Error rendering template: " + err.Error())) return -- cgit v1.2.3