Files
kouiz/internal/http/handler/webui/quiz/handler.go

35 lines
657 B
Go
Raw Normal View History

2025-06-10 21:09:58 +02:00
package quiz
import (
"net/http"
2025-06-13 16:55:46 +02:00
"time"
2025-06-10 21:09:58 +02:00
"forge.cadoles.com/wpetit/kouiz/internal/store"
)
type Handler struct {
2025-06-13 16:55:46 +02:00
mux *http.ServeMux
store *store.Store
playInterval time.Duration
2025-06-10 21:09:58 +02:00
}
// ServeHTTP implements http.Handler.
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.mux.ServeHTTP(w, r)
}
2025-06-13 16:55:46 +02:00
func NewHandler(store *store.Store, playInterval time.Duration) *Handler {
2025-06-10 21:09:58 +02:00
h := &Handler{
2025-06-13 16:55:46 +02:00
mux: http.NewServeMux(),
store: store,
playInterval: playInterval,
2025-06-10 21:09:58 +02:00
}
h.mux.HandleFunc("GET /", h.getQuizPage)
h.mux.HandleFunc("POST /", h.handleQuizForm)
return h
}
var _ http.Handler = &Handler{}