|
|
@ -95,11 +95,13 @@ func (s *server) HandleToggle() http.HandlerFunc {
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
http.Error(w, "Bad id", http.StatusBadRequest)
|
|
|
|
http.Error(w, "Bad id", http.StatusBadRequest)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = s.db.ToggleTodo(id)
|
|
|
|
err = s.db.ToggleTodo(id)
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
http.Error(w, "failed to toggle", http.StatusInternalServerError)
|
|
|
|
http.Error(w, "failed to toggle", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
|
|
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
|
|
|