diff --git a/app/controllers/comment.go b/app/controllers/comment.go index 431a4a1bab087354e551b59f56244150ac80c5eb..f16ec5bdb619508c86de64341f25b027bebd6932 100644 --- a/app/controllers/comment.go +++ b/app/controllers/comment.go @@ -47,12 +47,13 @@ func (c ApiComment) Index() revel.Result { func (c ApiComment) Create() revel.Result { var ( - comment string + comment, fields string postID uint post models.Post ) c.Params.Bind(&comment, "comment") + c.Params.Bind(&fields, "fields") c.Params.Bind(&postID, "id") user, err := models.CurrentUser(c.Params, c.Session) @@ -77,7 +78,8 @@ func (c ApiComment) Create() revel.Result { } go dispatcher.Run() - return c.Redirect("/") + // XXX that should return the comment + return c.RenderJSON(post) } func (c ApiComment) Show() revel.Result { diff --git a/app/controllers/post.go b/app/controllers/post.go index 0966a71323ff967fbdc256ec40fba55d9cedb5e3..d82f5a7cc72f55b1b75a5b2db4797c6f577ecc83 100644 --- a/app/controllers/post.go +++ b/app/controllers/post.go @@ -65,11 +65,12 @@ func (p ApiPost) Index() revel.Result { func (p ApiPost) Create() revel.Result { var ( post models.Post - postText string + postText, fields string aspectID uint ) p.Params.Bind(&postText, "post") + p.Params.Bind(&fields, "fields") p.Params.Bind(&aspectID, "aspectID") emptyPost, err := regexp.MatchString(`^\s*?$`, postText) @@ -144,7 +145,8 @@ func (p ApiPost) Create() revel.Result { } go dispatcher.Run() - return p.Redirect("/") + return p.RenderJSON( + apiHelpers.SelectStructFields(post, fields)) } func (p ApiPost) Show(guid string) revel.Result {