feat: initial commit
This commit is contained in:
41
internal/http/handler/api/handler.go
Normal file
41
internal/http/handler/api/handler.go
Normal file
@ -0,0 +1,41 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"forge.cadoles.com/wpetit/kouiz/internal/store"
|
||||
"forge.cadoles.com/wpetit/kouiz/internal/timex"
|
||||
"github.com/bornholm/genai/llm"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
mux *http.ServeMux
|
||||
store *store.Store
|
||||
llm llm.Client
|
||||
|
||||
playInterval time.Duration
|
||||
playPeriod timex.PeriodType
|
||||
}
|
||||
|
||||
// ServeHTTP implements http.Handler.
|
||||
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
h.mux.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func NewHandler(store *store.Store, llm llm.Client, playInterval time.Duration, playPeriod timex.PeriodType) *Handler {
|
||||
h := &Handler{
|
||||
mux: http.NewServeMux(),
|
||||
store: store,
|
||||
llm: llm,
|
||||
playInterval: playInterval,
|
||||
playPeriod: playPeriod,
|
||||
}
|
||||
|
||||
h.mux.HandleFunc("GET /presentation/leaderboard", h.getLeaderboardPresentation)
|
||||
h.mux.HandleFunc("GET /presentation/turn", h.getTurnPresentation)
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
var _ http.Handler = &Handler{}
|
Reference in New Issue
Block a user