summaryrefslogtreecommitdiff
path: root/system/api/create.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-05-24 02:54:38 -0700
committerGitHub <noreply@github.com>2017-05-24 02:54:38 -0700
commit47d5ad5e4233b35cb9296835f135055986c9e7ee (patch)
treea21e7ccfd437206a298b9cfd89e853377b599695 /system/api/create.go
parente97450a30b24c747d3c3702329a27bb70eeb9b34 (diff)
parentf24c9896a0e91235d0190f617f05cee0256fc2e9 (diff)
Merge pull request #149 from ponzu-cms/ponzu-dev
[core] deserialize content data into item.Hookable method receivers
Diffstat (limited to 'system/api/create.go')
-rw-r--r--system/api/create.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/system/api/create.go b/system/api/create.go
index 3328bd6..3b748cc 100644
--- a/system/api/create.go
+++ b/system/api/create.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"
)
// Createable accepts or rejects external POST requests to endpoints such as:
@@ -131,6 +133,17 @@ func createContentHandler(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.StatusBadRequest)
+ return
+ }
+
err = hook.BeforeAPICreate(res, req)
if err != nil {
log.Println("[Create] error calling BeforeAccept:", err)