|
|
|
@ -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))
|
|
|
|
|