diff --git a/go-web-app/gowiki/cmd/gowiki/main.go b/go-web-app/gowiki/cmd/gowiki/main.go index 20640f8..62c933f 100644 --- a/go-web-app/gowiki/cmd/gowiki/main.go +++ b/go-web-app/gowiki/cmd/gowiki/main.go @@ -155,6 +155,10 @@ func saveHandler(w http.ResponseWriter, r *http.Request, title string) { http.Redirect(w, r, "/view/"+title, http.StatusFound) } +func frontPageHandler(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, filepath.Join("/view", "FrontPage"), http.StatusFound) +} + func main() { log.Printf("%s\n", templates.DefinedTemplates()) // Using function literal and closures to handle not found @@ -164,6 +168,7 @@ func main() { http.HandleFunc("/view/", makeHandler(viewHandler)) http.HandleFunc("/edit/", makeHandler(editHandler)) http.HandleFunc("/save/", makeHandler(saveHandler)) + http.HandleFunc("/", frontPageHandler) log.Println("Serving on: http://0.0.0.0:5001") log.Fatal(http.ListenAndServe(":5001", nil))