Skip to content

Commit

Permalink
Apply static handling fix to all servers
Browse files Browse the repository at this point in the history
  • Loading branch information
jmshrv committed Mar 21, 2024
1 parent 8719f1f commit 8473e77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ballot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func main() {
log.Fatal("could not fetch candidate list.", err)
}

r := mux.NewRouter()
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
r := mux.NewRouter().PathPrefix("/ballot").Subrouter()
r.PathPrefix("/static/").Handler(http.StripPrefix("/ballot/static/", http.FileServer(http.Dir("./static/"))))
r.Path("/candidates/").HandlerFunc(handleCandidates)
r.Path("/active/{id}/").HandlerFunc(handleActive)
r.Path("/submit/").Methods("POST").HandlerFunc(handleSubmit)
Expand Down
4 changes: 2 additions & 2 deletions registration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func main() {
log.Fatal("could not connect to the database.", err)
}

r := mux.NewRouter()
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
r := mux.NewRouter().PathPrefix("/register").Subrouter()
r.PathPrefix("/static/").Handler(http.StripPrefix("/register/static/", http.FileServer(http.Dir("./static/"))))
r.Path("/register/").Methods("POST").HandlerFunc(registerHandler)
r.Path("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "./static/index.html")
Expand Down

0 comments on commit 8473e77

Please sign in to comment.