Commits

Yann Malet  committed 1a16066

Reverse URL instead of hardcoding it

  • Participants
  • Parent commits a18dbbf

Comments (0)

Files changed (1)

 	return templates
 }
 
-// Implement a sigleton Pattern
+// Implement a singleton Pattern
 type WebApp struct {
 	Router      *mux.Router
 	Storage     Storage
 			ctx["validationErrors"] = validationErrors
 		} else {
 			App.Storage.AddPage(page)
-			// Redirect to / after the creation of the page
-			http.Redirect(w, r, "/pages/", 302)
+			// Redirect to /pages/ after the creation of the page
+			// retrieve the url from the Router
+			pages_url, err := App.Router.Get("page_list").URL()
+			if err != nil {
+				panic(err)
+			}
+			http.Redirect(w, r, pages_url.String(), 302)
 		}
 	}