aboutsummaryrefslogblamecommitdiff
path: root/http_handle_index.go
blob: ee92c495b4b543e1b08b3dcb7bd6e1a25f1c1082 (plain) (tree)
1
2
3
4
5
6
7
8
9





                  
                                                                                  
                                                                                                              
                       
                                                                                                    

                      
                                 
                                                           
                       
                                                                                                       

                      
 
package main

import (
	"net/http"
)

func handle_index(w http.ResponseWriter, r *http.Request, params map[string]any) {
	groups, err := query_name_desc_list(r.Context(), "SELECT name, COALESCE(description, '') FROM groups")
	if err != nil {
		http.Error(w, "Error querying groups: "+err.Error(), http.StatusInternalServerError)
		return
	}
	params["groups"] = groups
	err = templates.ExecuteTemplate(w, "index", params)
	if err != nil {
		http.Error(w, "Error rendering template: "+err.Error(), http.StatusInternalServerError)
		return
	}
}