func BoardUpdate(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { r.ParseForm() article := new(domain.Article) decoder := schema.NewDecoder() // hm... I consider to make this variable global variable decoder.Decode(article, r.PostForm) log.Println("Bofore Updated Article :", article) id, err := strconv.Atoi(ps.ByName("id")) checkIsNumber(err, w, r) article.Id = id repository.Update(article) data := map[string]interface{}{"article": repository.GetOneArticle(id)} makeTemplateExcute("read", data, w) }
func BoardFormUpdate(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { id, err := strconv.Atoi(ps.ByName("id")) checkIsNumber(err, w, r) data := map[string]interface{}{"article": repository.GetOneArticle(id)} makeTemplateExcute("formUpdate", data, w) }