Files
qv/cmd/web/routes.go
2025-01-11 18:29:01 +01:00

26 lines
567 B
Go

package main
import (
"code.dlmw.ch/dlmw/qv/internal/models"
"github.com/justinas/alice"
"log/slog"
"net/http"
)
type application struct {
logger *slog.Logger
elections models.ElectionModelInterface
voters models.VoterModelInterface
votes models.VoteModelInterface
}
func (app *application) routes() http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("POST /election", app.createElection)
mux.HandleFunc("POST /election/{id}/votes", app.createVotes)
standard := alice.New(app.recoverPanic, app.logRequest)
return standard.Then(mux)
}