package session import ( "fmt" "log" "net/http" "streifling.com/jason/sicherheitsunterweisung/packages/data" ) func NewMux() *Mux { mux := new(Mux) mux.ServeMux = http.NewServeMux() return mux } func (mux *Mux) HandleSessions(db *data.DB, cs <-chan *Session, ss *[]*Session) { for s := range cs { (*ss) = append(*ss, s) participantChan := make(chan *data.Participant) questionIDs := make([]string, 4) for i := 0; i < len(questionIDs); i++ { questionIDs[i] = fmt.Sprint(i + 1) } var err error s.Questions, err = db.GetQuestions(questionIDs) if err != nil { log.Fatalln(err) } mux.HandleFunc("/new-briefing/"+fmt.Sprint(s.ID)+"/", s.HandleNewBriefing()) mux.HandleFunc("/new-participant/"+fmt.Sprint(s.ID)+"/", s.HandleNewParticipant(participantChan)) mux.HandleFunc("/submit-form/"+fmt.Sprint(s.ID)+"/", s.HandleBriefingForm(db)) go mux.handleParticipants(db, participantChan, s) } }