Add page for results
This commit is contained in:
@ -39,6 +39,17 @@ func (app *application) createElectionPage(w http.ResponseWriter, r *http.Reques
|
||||
w.Write(content)
|
||||
}
|
||||
|
||||
func (app *application) getElectionResultsPage(w http.ResponseWriter, r *http.Request) {
|
||||
content, err := ui.Files.ReadFile("election-results.html")
|
||||
if err != nil {
|
||||
app.serverError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Write(content)
|
||||
}
|
||||
|
||||
func (app *application) getElectionPage(w http.ResponseWriter, r *http.Request) {
|
||||
content, err := ui.Files.ReadFile("election.html")
|
||||
if err != nil {
|
||||
|
@ -24,6 +24,7 @@ func (app *application) routes() http.Handler {
|
||||
|
||||
mux.HandleFunc("GET /", app.indexPage)
|
||||
mux.HandleFunc("GET /election/create", app.createElectionPage)
|
||||
mux.HandleFunc("GET /election/{id}/results", app.getElectionResultsPage)
|
||||
mux.HandleFunc("GET /election/{id}", app.getElectionPage)
|
||||
|
||||
api.HandlerWithOptions(app, api.StdHTTPServerOptions{
|
||||
|
Reference in New Issue
Block a user