DB konstant als ersten Funktionsparameter gesetzt
This commit is contained in:
parent
387f662355
commit
e3fb756bb1
4
main.go
4
main.go
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
func handleParticipants(mux *http.ServeMux, db *data.DB, cp <-chan *data.Participant, s *session.Session) {
|
func handleParticipants(mux *http.ServeMux, db *data.DB, cp <-chan *data.Participant, s *session.Session) {
|
||||||
for participant := range cp {
|
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 {
|
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)))
|
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) {
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
template.Must(template.ParseFiles("templates/index.html", "templates/login.html")).Execute(w, nil)
|
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("/external-login/", session.HandleExternalLogin(&sessions))
|
||||||
mux.HandleFunc("/search/", session.HandleSearch(db))
|
mux.HandleFunc("/search/", session.HandleSearch(db))
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"streifling.com/jason/sicherheitsunterweisung/packages/data"
|
"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) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
instructors, err := db.GetInstructors()
|
instructors, err := db.GetInstructors()
|
||||||
if err != nil {
|
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) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
p.FirstName = r.PostFormValue("first-" + fmt.Sprint(p.Login))
|
p.FirstName = r.PostFormValue("first-" + fmt.Sprint(p.Login))
|
||||||
p.LastName = r.PostFormValue("last-" + fmt.Sprint(p.Login))
|
p.LastName = r.PostFormValue("last-" + fmt.Sprint(p.Login))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user