From f24c9896a0e91235d0190f617f05cee0256fc2e9 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Wed, 24 May 2017 02:52:31 -0700 Subject: populate item hookable in API update --- system/api/update.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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) -- cgit v1.2.3