An allen wichtigen Stellen fmt.Errorf() durch http.Error() ersetzt
This commit is contained in:
parent
9bdc6e9f43
commit
c22647edd9
@ -25,7 +25,7 @@ func DisplayTable(db *data.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
bs, err := db.GetAllOverviewTableData()
|
||||
if err != nil {
|
||||
_ = fmt.Errorf("DisplayTable: *DB.GetAllOverviewTableData(): %v\n", err)
|
||||
http.Error(w, "DisplayTable: *DB.GetAllOverviewTableData(): "+fmt.Sprint(err), http.StatusInternalServerError)
|
||||
}
|
||||
template.Must(template.ParseFiles("templates/table.html")).ExecuteTemplate(w, "content", bs)
|
||||
}
|
||||
@ -33,9 +33,9 @@ func DisplayTable(db *data.DB) http.HandlerFunc {
|
||||
|
||||
func DisplaySearchResults(db *data.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
bs, err := db.ReadByName(r.PostFormValue("search"))
|
||||
bs, err := db.GetOverviewTableDataByName(r.PostFormValue("search"))
|
||||
if err != nil {
|
||||
_ = fmt.Errorf("DisplayResults: db.ReadByName(r.PostFormValue()): %v\n", err)
|
||||
http.Error(w, "DisplayResults: db.ReadByName(r.PostFormValue()): "+fmt.Sprint(err), http.StatusInternalServerError)
|
||||
}
|
||||
template.Must(template.ParseFiles("templates/table.html")).ExecuteTemplate(w, "rows", bs)
|
||||
}
|
||||
@ -47,21 +47,25 @@ func DisplayForm(i *int64) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func generateUUID() string {
|
||||
func generateUUID() (string, error) {
|
||||
bs := make([]byte, 2)
|
||||
|
||||
if _, err := rand.Read(bs); err != nil {
|
||||
_ = fmt.Errorf("GenerateUUID: rand.Read(bs): %v\n", err)
|
||||
return ""
|
||||
return "", fmt.Errorf("GenerateUUID: rand.Read(bs): %v\n", err)
|
||||
}
|
||||
|
||||
return hex.EncodeToString(bs)
|
||||
return hex.EncodeToString(bs), nil
|
||||
}
|
||||
|
||||
func AddParticipant(i *int64, ls *[]string) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
uuid, err := generateUUID()
|
||||
if err != nil {
|
||||
http.Error(w, "AddParticipant: generateUUID(): "+fmt.Sprint(err), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
*i++
|
||||
login := fmt.Sprintf("%d", *i) + "-" + generateUUID()
|
||||
login := fmt.Sprintf("%d", *i) + "-" + uuid
|
||||
(*ls) = append(*ls, login)
|
||||
template.Must(template.ParseFiles("templates/briefing.html")).ExecuteTemplate(w, "new", login)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user