Add create-election.html
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
api "code.dlmw.ch/dlmw/qv/internal"
|
||||
"code.dlmw.ch/dlmw/qv/internal/models"
|
||||
"code.dlmw.ch/dlmw/qv/internal/validator"
|
||||
"code.dlmw.ch/dlmw/qv/ui"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@ -15,6 +16,17 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func (app *application) createElectionPage(w http.ResponseWriter, r *http.Request) {
|
||||
content, err := ui.Files.ReadFile("create-election.html")
|
||||
if err != nil {
|
||||
app.serverError(w, r, fmt.Errorf("couldn't read create-election.html"))
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Write(content)
|
||||
}
|
||||
|
||||
type createElectionRequestWithValidator struct {
|
||||
api.CreateElectionRequest
|
||||
validator.Validator
|
||||
|
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"code.dlmw.ch/dlmw/qv/internal/models"
|
||||
"code.dlmw.ch/dlmw/qv/ui"
|
||||
"github.com/justinas/alice"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
@ -17,6 +18,9 @@ type application struct {
|
||||
func (app *application) routes() http.Handler {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.Handle("GET /static/", http.FileServerFS(ui.Files))
|
||||
mux.HandleFunc("GET /election/create", app.createElectionPage)
|
||||
|
||||
mux.HandleFunc("POST /election", app.createElection)
|
||||
mux.HandleFunc("POST /election/{id}/votes", app.createVotes)
|
||||
|
||||
|
Reference in New Issue
Block a user