diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-05-24 02:52:31 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2017-05-24 02:52:31 -0700 |
commit | f24c9896a0e91235d0190f617f05cee0256fc2e9 (patch) | |
tree | a21e7ccfd437206a298b9cfd89e853377b599695 /system | |
parent | e78a2994d80354f641e5656ec79a789a58d69276 (diff) |
populate item hookable in API update
Diffstat (limited to 'system')
-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) |