feat: initial commit
This commit is contained in:
@ -5,12 +5,14 @@ import (
|
||||
"time"
|
||||
|
||||
"forge.cadoles.com/wpetit/kouiz/internal/store"
|
||||
"forge.cadoles.com/wpetit/kouiz/internal/timex"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
mux *http.ServeMux
|
||||
store *store.Store
|
||||
playInterval time.Duration
|
||||
playPeriod timex.PeriodType
|
||||
}
|
||||
|
||||
// ServeHTTP implements http.Handler.
|
||||
@ -18,15 +20,19 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
h.mux.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func NewHandler(store *store.Store, playInterval time.Duration) *Handler {
|
||||
func NewHandler(store *store.Store, playInterval time.Duration, playPeriod timex.PeriodType) *Handler {
|
||||
h := &Handler{
|
||||
mux: http.NewServeMux(),
|
||||
store: store,
|
||||
playInterval: playInterval,
|
||||
playPeriod: playPeriod,
|
||||
}
|
||||
|
||||
h.mux.HandleFunc("GET /", h.getQuizPage)
|
||||
h.mux.HandleFunc("POST /", h.handleQuizForm)
|
||||
h.mux.HandleFunc("GET /leaderboard", h.getLeadeboardPage)
|
||||
h.mux.HandleFunc("POST /select", h.handleSelectEntryForm)
|
||||
h.mux.HandleFunc("POST /answer", h.handleAnswerForm)
|
||||
h.mux.HandleFunc("GET /result", h.getResultPage)
|
||||
|
||||
return h
|
||||
}
|
||||
|
Reference in New Issue
Block a user