37 lines
807 B
Go
37 lines
807 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"streifling.com/jason/sicherheitsunterweisung/packages/db"
|
|
"streifling.com/jason/sicherheitsunterweisung/packages/server"
|
|
"streifling.com/jason/sicherheitsunterweisung/packages/types"
|
|
)
|
|
|
|
func main() {
|
|
var i, j int64
|
|
|
|
i, j = 1, 1
|
|
mux := http.NewServeMux()
|
|
cb := make(chan *types.Briefing)
|
|
|
|
db, err := db.OpenDB("sicherheitsunterweisung")
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
|
|
mux.HandleFunc("/", server.DisplayForm(&i))
|
|
mux.HandleFunc("/add-participant/", server.AddParticipant(&i))
|
|
mux.HandleFunc("/submit/", server.SubmitForm(cb, &i, &j))
|
|
|
|
go func() {
|
|
for b := range cb {
|
|
db.WriteBriefing(b)
|
|
}
|
|
}()
|
|
|
|
log.Fatalln(http.ListenAndServe(":8080", mux))
|
|
}
|