From e3fb756bb101fc52fda4edafbe87af0e295b613e Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sat, 28 Oct 2023 09:03:19 +0200 Subject: [PATCH] DB konstant als ersten Funktionsparameter gesetzt --- main.go | 4 ++-- packages/session/handlerFuncs.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 630ac67..8d3139c 100644 --- a/main.go +++ b/main.go @@ -12,7 +12,7 @@ import ( func handleParticipants(mux *http.ServeMux, db *data.DB, cp <-chan *data.Participant, s *session.Session) { for participant := range cp { - mux.HandleFunc("/submit-participant/"+fmt.Sprint(s.ID)+"/"+fmt.Sprint(participant.Login)+"/", s.HandleParticipant(participant, &s.Questions, db)) + mux.HandleFunc("/submit-participant/"+fmt.Sprint(s.ID)+"/"+fmt.Sprint(participant.Login)+"/", s.HandleParticipant(db, participant, &s.Questions)) for i := range s.Questions { mux.HandleFunc("/submit-answer/"+fmt.Sprint(s.ID)+"/"+fmt.Sprint(participant.Login)+"/"+fmt.Sprint(i+1)+"/", s.HandleAnswer(db, participant, &s.Questions, int64(i+1))) } @@ -58,7 +58,7 @@ func main() { mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { template.Must(template.ParseFiles("templates/index.html", "templates/login.html")).Execute(w, nil) }) - mux.HandleFunc("/internal-login/", session.HandleInternalLogin(&sessions, sessionChan, db)) + mux.HandleFunc("/internal-login/", session.HandleInternalLogin(db, &sessions, sessionChan)) mux.HandleFunc("/external-login/", session.HandleExternalLogin(&sessions)) mux.HandleFunc("/search/", session.HandleSearch(db)) diff --git a/packages/session/handlerFuncs.go b/packages/session/handlerFuncs.go index 43b98bc..7a0763f 100644 --- a/packages/session/handlerFuncs.go +++ b/packages/session/handlerFuncs.go @@ -11,7 +11,7 @@ import ( "streifling.com/jason/sicherheitsunterweisung/packages/data" ) -func HandleInternalLogin(ss *[]*Session, cs chan<- *Session, db *data.DB) http.HandlerFunc { +func HandleInternalLogin(db *data.DB, ss *[]*Session, cs chan<- *Session) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { instructors, err := db.GetInstructors() if err != nil { @@ -112,7 +112,7 @@ func HandleExternalLogin(ss *[]*Session) http.HandlerFunc { } } -func (s *Session) HandleParticipant(p *data.Participant, sq *[]data.Question, db *data.DB) http.HandlerFunc { +func (s *Session) HandleParticipant(db *data.DB, p *data.Participant, sq *[]data.Question) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { p.FirstName = r.PostFormValue("first-" + fmt.Sprint(p.Login)) p.LastName = r.PostFormValue("last-" + fmt.Sprint(p.Login))