diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-09-22 03:55:26 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-22 03:55:26 -0600 |
commit | e43cda203b2b3eadab6bea1891e83fe232555fb5 (patch) | |
tree | 3593e57025f2c2a90241afb3b4c97640416efdb3 | |
parent | 73c3900ab4a6fd97face9eee591b5116e0439bc8 (diff) | |
parent | 47c03ae3376dea2d7bfab8fdae6e71af9e465653 (diff) |
Merge pull request #195 from ponzu-cms/ponzu-dev
adding data to struct in Update procedure
-rw-r--r-- | system/api/update.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/system/api/update.go b/system/api/update.go index 31f29c1..91fbd8e 100644 --- a/system/api/update.go +++ b/system/api/update.go @@ -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) @@ -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) |