func Save(w http.ResponseWriter, r *http.Request) { var o db.Link decoder := json.NewDecoder(r.Body) err := decoder.Decode(&o) if err != nil { util.Error(err, w) return } err = o.Save() if err != nil { util.Error(err, w) return } err = o.Load() util.ToJSON(o, err, w) }
func testModels() { link := links.Link{ Title: "Test link", URL: "https://jess.lawrence.pm", } err := link.Save() if err != nil { panic(err) } log.Println(link) link.Title = "test link name change" err = link.Save() if err != nil { panic(err) } log.Println(link) err = utils.Insert(&link) if err != nil { panic(err) } err = link.AddTag("tag1") if err != nil { panic(err) } err = link.AddTag("tag2") if err != nil { panic(err) } err = link.RemoveTag("tag1") if err != nil { panic(err) } log.Println(link.Tags) }