Redirect properly after edit

This commit is contained in:
Las Zenow 2012-08-23 10:57:23 +02:00
parent d8b381edf8
commit 4351d9ec84

View file

@ -82,7 +82,8 @@ func saveHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request)
return return
} }
id := bson.ObjectIdHex(r.URL.Path[len("/save/"):]) idStr := r.URL.Path[len("/save/"):]
id := bson.ObjectIdHex(idStr)
title := r.FormValue("title") title := r.FormValue("title")
publisher := r.FormValue("publisher") publisher := r.FormValue("publisher")
date := r.FormValue("date") date := r.FormValue("date")
@ -104,7 +105,7 @@ func saveHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request)
sess.Notify("Book Modified!", "", "success") sess.Notify("Book Modified!", "", "success")
sess.Save(w, r) sess.Save(w, r)
http.Redirect(w, r, "/book/"+title, 307) http.Redirect(w, r, "/book/"+idStr, 307)
} }
} }