Files
qv/cmd/web/routes.go

30 lines
716 B
Go
Raw Normal View History

2024-12-27 18:03:46 +01:00
package main
import (
2024-12-31 15:29:19 +01:00
"code.dlmw.ch/dlmw/qv/internal/models"
2025-01-13 10:56:36 +01:00
"code.dlmw.ch/dlmw/qv/ui"
2024-12-27 18:03:46 +01:00
"github.com/justinas/alice"
2024-12-31 15:29:19 +01:00
"log/slog"
2024-12-27 18:03:46 +01:00
"net/http"
)
2024-12-31 15:29:19 +01:00
type application struct {
logger *slog.Logger
elections models.ElectionModelInterface
voters models.VoterModelInterface
2025-01-08 13:57:49 +01:00
votes models.VoteModelInterface
2024-12-31 15:29:19 +01:00
}
2024-12-27 18:03:46 +01:00
func (app *application) routes() http.Handler {
mux := http.NewServeMux()
2025-01-13 10:56:36 +01:00
mux.Handle("GET /static/", http.FileServerFS(ui.Files))
mux.HandleFunc("GET /election/create", app.createElectionPage)
2024-12-27 18:03:46 +01:00
mux.HandleFunc("POST /election", app.createElection)
mux.HandleFunc("POST /election/{id}/votes", app.createVotes)
2024-12-27 18:03:46 +01:00
standard := alice.New(app.recoverPanic, app.logRequest)
return standard.Then(mux)
}