diff --git a/packages/server/server.go b/packages/server/server.go index 2f70433..10ab54a 100644 --- a/packages/server/server.go +++ b/packages/server/server.go @@ -1,6 +1,8 @@ package server import ( + "crypto/rand" + "encoding/hex" "fmt" "html/template" "log" @@ -71,6 +73,19 @@ func SubmitForm(db *db.DB, i, j *int64) http.HandlerFunc { if err != nil { _ = fmt.Errorf("SubmitForm: db.ReadAll(): %v\n", err) } - template.Must(template.ParseFiles("templates/index.html", "templates/table.html")).Execute(w, bs) + template.Must(template.ParseFiles("templates/table.html")).Execute(w, bs) + } +} + +func GenerateUUID() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + bs := make([]byte, 4) + + _, err := rand.Read(bs) + if err != nil { + _ = fmt.Errorf("GenerateUUID: rand.Read(bs): %v\n", err) + } + + template.Must(template.ParseFiles("templates/form.html")).ExecuteTemplate(w, "uuid", hex.EncodeToString(bs)) } }