func (cr *DataController) Update(id string, cx *goweb.Context) { cx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*") cx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*") cx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "PUT") data := new(dataContainer) data.Model = cx.PathParams["model"] errs := cx.Fill(&data.Data) if errs != nil { log.Print(errs) cx.RespondWithError(500) } else { bucket, berr := couchbase.GetBucket("http://localhost:8091/", "default", "mking.me") if berr != nil { log.Print(berr) cx.WriteResponse(data, http.StatusInternalServerError) } else { data.Data["id"] = id errr := bucket.Set(id, 0, data) if errr != nil { log.Print(errr) cx.WriteResponse(data.Data, http.StatusInternalServerError) } else { cx.WriteResponse(data.Data, http.StatusOK) } } } }
func (p *Product) Fill(cx *goweb.Context) { cx.Fill(&p) }
func (p *Person) Fill(cx *goweb.Context) { cx.Fill(&p) }