diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-05-24 02:54:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-24 02:54:38 -0700 |
commit | 47d5ad5e4233b35cb9296835f135055986c9e7ee (patch) | |
tree | a21e7ccfd437206a298b9cfd89e853377b599695 /system/api/update.go | |
parent | e97450a30b24c747d3c3702329a27bb70eeb9b34 (diff) | |
parent | f24c9896a0e91235d0190f617f05cee0256fc2e9 (diff) |
Merge pull request #149 from ponzu-cms/ponzu-dev
[core] deserialize content data into item.Hookable method receivers
Diffstat (limited to 'system/api/update.go')
-rw-r--r-- | system/api/update.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/system/api/update.go b/system/api/update.go index 9414ab4..36ffaeb 100644 --- a/system/api/update.go +++ b/system/api/update.go @@ -12,6 +12,8 @@ import ( "github.com/ponzu-cms/ponzu/system/admin/upload" "github.com/ponzu-cms/ponzu/system/db" "github.com/ponzu-cms/ponzu/system/item" + + "github.com/gorilla/schema" ) // Updateable accepts or rejects update POST requests to endpoints such as: @@ -132,6 +134,17 @@ func updateContentHandler(res http.ResponseWriter, req *http.Request) { return } + // Let's be nice and make a proper item for the Hookable methods + dec := schema.NewDecoder() + dec.IgnoreUnknownKeys(true) + dec.SetAliasTag("json") + err = dec.Decode(post, req.PostForm) + if err != nil { + log.Println("Error decoding post form for edit handler:", t, err) + res.WriteHeader(http.StatusInternalServerError) + return + } + err = hook.BeforeAPIUpdate(res, req) if err != nil { log.Println("[Update] error calling BeforeAPIUpdate:", err) |