Skip to content

Commit

Permalink
Merge pull request #195 from ponzu-cms/ponzu-dev
Browse files Browse the repository at this point in the history
adding data to struct in Update procedure
  • Loading branch information
nilslice committed Sep 22, 2017
2 parents 73c3900 + 47c03ae commit e43cda2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion system/api/update.go
Expand Up @@ -58,6 +58,20 @@ func updateContentHandler(res http.ResponseWriter, req *http.Request) {

post := p()

j, err := db.Content(t + ":" + id)
if err != nil {
log.Println("[Update] error getting content for type:", t, err)
res.WriteHeader(http.StatusInternalServerError)
return
}

err = json.Unmarshal(j, post)
if err != nil {
log.Println("[Update] error populating data in type:", t, err)
res.WriteHeader(http.StatusInternalServerError)
return
}

ext, ok := post.(Updateable)
if !ok {
log.Println("[Update] rejected non-updateable type:", t, "from:", req.RemoteAddr)
Expand Down Expand Up @@ -221,7 +235,7 @@ func updateContentHandler(res http.ResponseWriter, req *http.Request) {
},
}

j, err := json.Marshal(resp)
j, err = json.Marshal(resp)
if err != nil {
log.Println("[Update] error marshalling response to JSON:", err)
res.WriteHeader(http.StatusInternalServerError)
Expand Down

0 comments on commit e43cda2

Please sign in to comment.