Add index page and link to share more easily
This commit is contained in:
@ -17,6 +17,17 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func (app *application) indexPage(w http.ResponseWriter, r *http.Request) {
|
||||
content, err := ui.Files.ReadFile("index.html")
|
||||
if err != nil {
|
||||
app.serverError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Write(content)
|
||||
}
|
||||
|
||||
func (app *application) createElectionPage(w http.ResponseWriter, r *http.Request) {
|
||||
content, err := ui.Files.ReadFile("create-election.html")
|
||||
if err != nil {
|
||||
|
@ -22,6 +22,7 @@ func (app *application) routes() http.Handler {
|
||||
cached := alice.New(app.cacheStatic)
|
||||
mux.Handle("GET /static/", cached.Then(http.FileServerFS(ui.Files)))
|
||||
|
||||
mux.HandleFunc("GET /", app.indexPage)
|
||||
mux.HandleFunc("GET /election/create", app.createElectionPage)
|
||||
mux.HandleFunc("GET /election/{id}", app.getElectionPage)
|
||||
|
||||
|
Reference in New Issue
Block a user